From 88e4cbb448d7edc59b1f866d61dd6f6d65071d5d Mon Sep 17 00:00:00 2001 From: tlento Date: Thu, 13 Jun 2024 17:17:42 -0700 Subject: [PATCH] Update engine snapshots --- ...ion_metric_with_time_constraint__plan0.sql | 622 +++---- ..._with_time_constraint__plan0_optimized.sql | 70 +- ...with_window_and_time_constraint__plan0.sql | 654 +++---- ...w_and_time_constraint__plan0_optimized.sql | 86 +- ...ion_metric_with_time_constraint__plan0.sql | 628 +++---- ..._with_time_constraint__plan0_optimized.sql | 72 +- ...with_window_and_time_constraint__plan0.sql | 666 +++---- ...w_and_time_constraint__plan0_optimized.sql | 90 +- ...ion_metric_with_time_constraint__plan0.sql | 628 +++---- ..._with_time_constraint__plan0_optimized.sql | 72 +- ...with_window_and_time_constraint__plan0.sql | 666 +++---- ...w_and_time_constraint__plan0_optimized.sql | 90 +- ...ion_metric_with_time_constraint__plan0.sql | 628 +++---- ..._with_time_constraint__plan0_optimized.sql | 72 +- ...with_window_and_time_constraint__plan0.sql | 666 +++---- ...w_and_time_constraint__plan0_optimized.sql | 90 +- ...ion_metric_with_time_constraint__plan0.sql | 628 +++---- ..._with_time_constraint__plan0_optimized.sql | 72 +- ...with_window_and_time_constraint__plan0.sql | 666 +++---- ...w_and_time_constraint__plan0_optimized.sql | 90 +- ...ion_metric_with_time_constraint__plan0.sql | 628 +++---- ..._with_time_constraint__plan0_optimized.sql | 72 +- ...with_window_and_time_constraint__plan0.sql | 666 +++---- ...w_and_time_constraint__plan0_optimized.sql | 90 +- .../test_cumulative_metric_month__plan0.sql | 172 +- ...mulative_metric_month__plan0_optimized.sql | 16 +- ..._no_window_with_time_constraint__plan0.sql | 260 +-- ..._with_time_constraint__plan0_optimized.sql | 14 +- ...ive_metric_with_time_constraint__plan0.sql | 262 +-- ..._with_time_constraint__plan0_optimized.sql | 16 +- .../test_cumulative_metric_month__plan0.sql | 176 +- ...mulative_metric_month__plan0_optimized.sql | 18 +- ..._no_window_with_time_constraint__plan0.sql | 264 +-- ..._with_time_constraint__plan0_optimized.sql | 16 +- ...ive_metric_with_time_constraint__plan0.sql | 264 +-- ..._with_time_constraint__plan0_optimized.sql | 18 +- .../test_cumulative_metric_month__plan0.sql | 176 +- ...mulative_metric_month__plan0_optimized.sql | 18 +- ..._no_window_with_time_constraint__plan0.sql | 264 +-- ..._with_time_constraint__plan0_optimized.sql | 16 +- ...ive_metric_with_time_constraint__plan0.sql | 264 +-- ..._with_time_constraint__plan0_optimized.sql | 18 +- .../test_cumulative_metric_month__plan0.sql | 176 +- ...mulative_metric_month__plan0_optimized.sql | 18 +- ..._no_window_with_time_constraint__plan0.sql | 264 +-- ..._with_time_constraint__plan0_optimized.sql | 16 +- ...ive_metric_with_time_constraint__plan0.sql | 264 +-- ..._with_time_constraint__plan0_optimized.sql | 18 +- .../test_cumulative_metric_month__plan0.sql | 176 +- ...mulative_metric_month__plan0_optimized.sql | 18 +- ..._no_window_with_time_constraint__plan0.sql | 264 +-- ..._with_time_constraint__plan0_optimized.sql | 16 +- ...ive_metric_with_time_constraint__plan0.sql | 264 +-- ..._with_time_constraint__plan0_optimized.sql | 18 +- .../test_cumulative_metric_month__plan0.sql | 176 +- ...mulative_metric_month__plan0_optimized.sql | 18 +- ..._no_window_with_time_constraint__plan0.sql | 264 +-- ..._with_time_constraint__plan0_optimized.sql | 16 +- ...ive_metric_with_time_constraint__plan0.sql | 264 +-- ..._with_time_constraint__plan0_optimized.sql | 18 +- .../test_multihop_joined_plan__ep_0.xml | 70 +- .../test_multihop_joined_plan__ep_0.xml | 70 +- .../test_multihop_joined_plan__ep_0.xml | 70 +- .../test_multihop_joined_plan__ep_0.xml | 70 +- .../test_multihop_joined_plan__ep_0.xml | 70 +- .../Trino/test_multihop_joined_plan__ep_0.xml | 70 +- .../BigQuery/test_nested_filters__plan0.sql | 1612 ++++++++--------- .../test_nested_filters__plan0_optimized.sql | 44 +- .../Databricks/test_nested_filters__plan0.sql | 1612 ++++++++--------- .../test_nested_filters__plan0_optimized.sql | 44 +- .../Postgres/test_nested_filters__plan0.sql | 1612 ++++++++--------- .../test_nested_filters__plan0_optimized.sql | 44 +- .../Redshift/test_nested_filters__plan0.sql | 1612 ++++++++--------- .../test_nested_filters__plan0_optimized.sql | 44 +- .../Snowflake/test_nested_filters__plan0.sql | 1612 ++++++++--------- .../test_nested_filters__plan0_optimized.sql | 44 +- .../Trino/test_nested_filters__plan0.sql | 1612 ++++++++--------- .../test_nested_filters__plan0_optimized.sql | 44 +- ...join_to_time_spine_with_filters__plan0.sql | 452 ++--- ...me_spine_with_filters__plan0_optimized.sql | 18 +- ...join_to_time_spine_with_filters__plan0.sql | 454 ++--- ...me_spine_with_filters__plan0_optimized.sql | 18 +- ...join_to_time_spine_with_filters__plan0.sql | 454 ++--- ...me_spine_with_filters__plan0_optimized.sql | 18 +- ...join_to_time_spine_with_filters__plan0.sql | 454 ++--- ...me_spine_with_filters__plan0_optimized.sql | 18 +- ...join_to_time_spine_with_filters__plan0.sql | 454 ++--- ...me_spine_with_filters__plan0_optimized.sql | 18 +- ...join_to_time_spine_with_filters__plan0.sql | 454 ++--- ...me_spine_with_filters__plan0_optimized.sql | 18 +- ...values_query_with_metric_filter__plan0.sql | 250 +-- ...ry_with_metric_filter__plan0_optimized.sql | 10 +- ...emantic_model_as_queried_metric__plan0.sql | 462 ++--- ...del_as_queried_metric__plan0_optimized.sql | 12 +- ...t_filter_with_conversion_metric__plan0.sql | 614 +++---- ...ith_conversion_metric__plan0_optimized.sql | 74 +- ...roup_by_has_local_entity_prefix__plan0.sql | 562 +++--- ...s_local_entity_prefix__plan0_optimized.sql | 12 +- .../test_inner_query_multi_hop__plan0.sql | 802 ++++---- ...inner_query_multi_hop__plan0_optimized.sql | 16 +- .../test_inner_query_single_hop__plan0.sql | 372 ++-- ...nner_query_single_hop__plan0_optimized.sql | 12 +- .../test_metric_filtered_by_itself__plan0.sql | 462 ++--- ...ic_filtered_by_itself__plan0_optimized.sql | 12 +- ...ric_with_metric_in_where_filter__plan0.sql | 414 ++--- ...etric_in_where_filter__plan0_optimized.sql | 16 +- ...mulative_metric_in_where_filter__plan0.sql | 276 +-- ...etric_in_where_filter__plan0_optimized.sql | 12 +- ..._derived_metric_in_where_filter__plan0.sql | 556 +++--- ...etric_in_where_filter__plan0_optimized.sql | 28 +- ...with_multiple_metrics_in_filter__plan0.sql | 632 +++---- ...ple_metrics_in_filter__plan0_optimized.sql | 20 +- ...th_ratio_metric_in_where_filter__plan0.sql | 634 +++---- ...etric_in_where_filter__plan0_optimized.sql | 26 +- ...h_simple_metric_in_where_filter__plan0.sql | 400 ++-- ...etric_in_where_filter__plan0_optimized.sql | 14 +- ...values_query_with_metric_filter__plan0.sql | 254 +-- ...ry_with_metric_filter__plan0_optimized.sql | 10 +- ...emantic_model_as_queried_metric__plan0.sql | 464 ++--- ...del_as_queried_metric__plan0_optimized.sql | 12 +- ...t_filter_with_conversion_metric__plan0.sql | 620 +++---- ...ith_conversion_metric__plan0_optimized.sql | 80 +- ...roup_by_has_local_entity_prefix__plan0.sql | 564 +++--- ...s_local_entity_prefix__plan0_optimized.sql | 12 +- .../test_inner_query_multi_hop__plan0.sql | 804 ++++---- ...inner_query_multi_hop__plan0_optimized.sql | 18 +- .../test_inner_query_single_hop__plan0.sql | 374 ++-- ...nner_query_single_hop__plan0_optimized.sql | 12 +- .../test_metric_filtered_by_itself__plan0.sql | 464 ++--- ...ic_filtered_by_itself__plan0_optimized.sql | 12 +- ...ric_with_metric_in_where_filter__plan0.sql | 418 ++--- ...etric_in_where_filter__plan0_optimized.sql | 16 +- ...mulative_metric_in_where_filter__plan0.sql | 278 +-- ...etric_in_where_filter__plan0_optimized.sql | 12 +- ..._derived_metric_in_where_filter__plan0.sql | 562 +++--- ...etric_in_where_filter__plan0_optimized.sql | 30 +- ...with_multiple_metrics_in_filter__plan0.sql | 636 +++---- ...ple_metrics_in_filter__plan0_optimized.sql | 20 +- ...th_ratio_metric_in_where_filter__plan0.sql | 640 +++---- ...etric_in_where_filter__plan0_optimized.sql | 28 +- ...h_simple_metric_in_where_filter__plan0.sql | 402 ++-- ...etric_in_where_filter__plan0_optimized.sql | 14 +- ...values_query_with_metric_filter__plan0.sql | 254 +-- ...ry_with_metric_filter__plan0_optimized.sql | 10 +- ...emantic_model_as_queried_metric__plan0.sql | 464 ++--- ...del_as_queried_metric__plan0_optimized.sql | 12 +- ...t_filter_with_conversion_metric__plan0.sql | 620 +++---- ...ith_conversion_metric__plan0_optimized.sql | 80 +- ...roup_by_has_local_entity_prefix__plan0.sql | 564 +++--- ...s_local_entity_prefix__plan0_optimized.sql | 12 +- .../test_inner_query_multi_hop__plan0.sql | 804 ++++---- ...inner_query_multi_hop__plan0_optimized.sql | 18 +- .../test_inner_query_single_hop__plan0.sql | 374 ++-- ...nner_query_single_hop__plan0_optimized.sql | 12 +- .../test_metric_filtered_by_itself__plan0.sql | 464 ++--- ...ic_filtered_by_itself__plan0_optimized.sql | 12 +- ...ric_with_metric_in_where_filter__plan0.sql | 418 ++--- ...etric_in_where_filter__plan0_optimized.sql | 16 +- ...mulative_metric_in_where_filter__plan0.sql | 278 +-- ...etric_in_where_filter__plan0_optimized.sql | 12 +- ..._derived_metric_in_where_filter__plan0.sql | 562 +++--- ...etric_in_where_filter__plan0_optimized.sql | 30 +- ...with_multiple_metrics_in_filter__plan0.sql | 636 +++---- ...ple_metrics_in_filter__plan0_optimized.sql | 20 +- ...th_ratio_metric_in_where_filter__plan0.sql | 640 +++---- ...etric_in_where_filter__plan0_optimized.sql | 28 +- ...h_simple_metric_in_where_filter__plan0.sql | 402 ++-- ...etric_in_where_filter__plan0_optimized.sql | 14 +- ...values_query_with_metric_filter__plan0.sql | 254 +-- ...ry_with_metric_filter__plan0_optimized.sql | 10 +- ...emantic_model_as_queried_metric__plan0.sql | 464 ++--- ...del_as_queried_metric__plan0_optimized.sql | 12 +- ...t_filter_with_conversion_metric__plan0.sql | 620 +++---- ...ith_conversion_metric__plan0_optimized.sql | 80 +- ...roup_by_has_local_entity_prefix__plan0.sql | 564 +++--- ...s_local_entity_prefix__plan0_optimized.sql | 12 +- .../test_inner_query_multi_hop__plan0.sql | 804 ++++---- ...inner_query_multi_hop__plan0_optimized.sql | 18 +- .../test_inner_query_single_hop__plan0.sql | 374 ++-- ...nner_query_single_hop__plan0_optimized.sql | 12 +- .../test_metric_filtered_by_itself__plan0.sql | 464 ++--- ...ic_filtered_by_itself__plan0_optimized.sql | 12 +- ...ric_with_metric_in_where_filter__plan0.sql | 418 ++--- ...etric_in_where_filter__plan0_optimized.sql | 16 +- ...mulative_metric_in_where_filter__plan0.sql | 278 +-- ...etric_in_where_filter__plan0_optimized.sql | 12 +- ..._derived_metric_in_where_filter__plan0.sql | 562 +++--- ...etric_in_where_filter__plan0_optimized.sql | 30 +- ...with_multiple_metrics_in_filter__plan0.sql | 636 +++---- ...ple_metrics_in_filter__plan0_optimized.sql | 20 +- ...th_ratio_metric_in_where_filter__plan0.sql | 640 +++---- ...etric_in_where_filter__plan0_optimized.sql | 28 +- ...h_simple_metric_in_where_filter__plan0.sql | 402 ++-- ...etric_in_where_filter__plan0_optimized.sql | 14 +- ...values_query_with_metric_filter__plan0.sql | 254 +-- ...ry_with_metric_filter__plan0_optimized.sql | 10 +- ...emantic_model_as_queried_metric__plan0.sql | 464 ++--- ...del_as_queried_metric__plan0_optimized.sql | 12 +- ...t_filter_with_conversion_metric__plan0.sql | 620 +++---- ...ith_conversion_metric__plan0_optimized.sql | 80 +- ...roup_by_has_local_entity_prefix__plan0.sql | 564 +++--- ...s_local_entity_prefix__plan0_optimized.sql | 12 +- .../test_inner_query_multi_hop__plan0.sql | 804 ++++---- ...inner_query_multi_hop__plan0_optimized.sql | 18 +- .../test_inner_query_single_hop__plan0.sql | 374 ++-- ...nner_query_single_hop__plan0_optimized.sql | 12 +- .../test_metric_filtered_by_itself__plan0.sql | 464 ++--- ...ic_filtered_by_itself__plan0_optimized.sql | 12 +- ...ric_with_metric_in_where_filter__plan0.sql | 418 ++--- ...etric_in_where_filter__plan0_optimized.sql | 16 +- ...mulative_metric_in_where_filter__plan0.sql | 278 +-- ...etric_in_where_filter__plan0_optimized.sql | 12 +- ..._derived_metric_in_where_filter__plan0.sql | 562 +++--- ...etric_in_where_filter__plan0_optimized.sql | 30 +- ...with_multiple_metrics_in_filter__plan0.sql | 636 +++---- ...ple_metrics_in_filter__plan0_optimized.sql | 20 +- ...th_ratio_metric_in_where_filter__plan0.sql | 640 +++---- ...etric_in_where_filter__plan0_optimized.sql | 28 +- ...h_simple_metric_in_where_filter__plan0.sql | 402 ++-- ...etric_in_where_filter__plan0_optimized.sql | 14 +- ...values_query_with_metric_filter__plan0.sql | 254 +-- ...ry_with_metric_filter__plan0_optimized.sql | 10 +- ...emantic_model_as_queried_metric__plan0.sql | 464 ++--- ...del_as_queried_metric__plan0_optimized.sql | 12 +- ...t_filter_with_conversion_metric__plan0.sql | 620 +++---- ...ith_conversion_metric__plan0_optimized.sql | 80 +- ...roup_by_has_local_entity_prefix__plan0.sql | 564 +++--- ...s_local_entity_prefix__plan0_optimized.sql | 12 +- .../test_inner_query_multi_hop__plan0.sql | 804 ++++---- ...inner_query_multi_hop__plan0_optimized.sql | 18 +- .../test_inner_query_single_hop__plan0.sql | 374 ++-- ...nner_query_single_hop__plan0_optimized.sql | 12 +- .../test_metric_filtered_by_itself__plan0.sql | 464 ++--- ...ic_filtered_by_itself__plan0_optimized.sql | 12 +- ...ric_with_metric_in_where_filter__plan0.sql | 418 ++--- ...etric_in_where_filter__plan0_optimized.sql | 16 +- ...mulative_metric_in_where_filter__plan0.sql | 278 +-- ...etric_in_where_filter__plan0_optimized.sql | 12 +- ..._derived_metric_in_where_filter__plan0.sql | 562 +++--- ...etric_in_where_filter__plan0_optimized.sql | 30 +- ...with_multiple_metrics_in_filter__plan0.sql | 636 +++---- ...ple_metrics_in_filter__plan0_optimized.sql | 20 +- ...th_ratio_metric_in_where_filter__plan0.sql | 640 +++---- ...etric_in_where_filter__plan0_optimized.sql | 28 +- ...h_simple_metric_in_where_filter__plan0.sql | 402 ++-- ...etric_in_where_filter__plan0_optimized.sql | 14 +- ...re_source_categorical_dimension__plan0.sql | 664 +++---- ...categorical_dimension__plan0_optimized.sql | 18 +- ..._categorical_dimension_pushdown__plan0.sql | 342 ++-- ...al_dimension_pushdown__plan0_optimized.sql | 16 +- ..._categorical_dimension_pushdown__plan0.sql | 594 +++--- ...al_dimension_pushdown__plan0_optimized.sql | 12 +- ...re_source_categorical_dimension__plan0.sql | 670 +++---- ...categorical_dimension__plan0_optimized.sql | 20 +- ..._categorical_dimension_pushdown__plan0.sql | 344 ++-- ...al_dimension_pushdown__plan0_optimized.sql | 16 +- ..._categorical_dimension_pushdown__plan0.sql | 596 +++--- ...al_dimension_pushdown__plan0_optimized.sql | 12 +- ...re_source_categorical_dimension__plan0.sql | 670 +++---- ...categorical_dimension__plan0_optimized.sql | 20 +- ..._categorical_dimension_pushdown__plan0.sql | 344 ++-- ...al_dimension_pushdown__plan0_optimized.sql | 16 +- ..._categorical_dimension_pushdown__plan0.sql | 596 +++--- ...al_dimension_pushdown__plan0_optimized.sql | 12 +- ...re_source_categorical_dimension__plan0.sql | 670 +++---- ...categorical_dimension__plan0_optimized.sql | 20 +- ..._categorical_dimension_pushdown__plan0.sql | 344 ++-- ...al_dimension_pushdown__plan0_optimized.sql | 16 +- ..._categorical_dimension_pushdown__plan0.sql | 596 +++--- ...al_dimension_pushdown__plan0_optimized.sql | 12 +- ...re_source_categorical_dimension__plan0.sql | 670 +++---- ...categorical_dimension__plan0_optimized.sql | 20 +- ..._categorical_dimension_pushdown__plan0.sql | 344 ++-- ...al_dimension_pushdown__plan0_optimized.sql | 16 +- ..._categorical_dimension_pushdown__plan0.sql | 596 +++--- ...al_dimension_pushdown__plan0_optimized.sql | 12 +- ...re_source_categorical_dimension__plan0.sql | 670 +++---- ...categorical_dimension__plan0_optimized.sql | 20 +- ..._categorical_dimension_pushdown__plan0.sql | 344 ++-- ...al_dimension_pushdown__plan0_optimized.sql | 16 +- ..._categorical_dimension_pushdown__plan0.sql | 596 +++--- ...al_dimension_pushdown__plan0_optimized.sql | 12 +- ..._constraint_with_reused_measure__plan0.sql | 664 +++---- ...t_with_reused_measure__plan0_optimized.sql | 18 +- ...aint_with_single_expr_and_alias__plan0.sql | 434 ++--- ...single_expr_and_alias__plan0_optimized.sql | 6 +- ...multi_hop_through_scd_dimension__plan0.sql | 440 ++--- ...through_scd_dimension__plan0_optimized.sql | 18 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 406 ++--- ..._hop_to_scd_dimension__plan0_optimized.sql | 18 +- .../BigQuery/test_multihop_node__plan0.sql | 600 +++--- .../test_multihop_node__plan0_optimized.sql | 8 +- ..._multiple_metrics_no_dimensions__plan0.sql | 704 +++---- ...metrics_no_dimensions__plan0_optimized.sql | 8 +- ..._constraint_with_reused_measure__plan0.sql | 670 +++---- ...t_with_reused_measure__plan0_optimized.sql | 20 +- ...aint_with_single_expr_and_alias__plan0.sql | 436 ++--- ...single_expr_and_alias__plan0_optimized.sql | 6 +- ...multi_hop_through_scd_dimension__plan0.sql | 444 ++--- ...through_scd_dimension__plan0_optimized.sql | 22 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 410 ++--- ..._hop_to_scd_dimension__plan0_optimized.sql | 22 +- .../Databricks/test_multihop_node__plan0.sql | 602 +++--- .../test_multihop_node__plan0_optimized.sql | 10 +- ..._multiple_metrics_no_dimensions__plan0.sql | 704 +++---- ...metrics_no_dimensions__plan0_optimized.sql | 8 +- ..._constraint_with_reused_measure__plan0.sql | 670 +++---- ...t_with_reused_measure__plan0_optimized.sql | 20 +- ...aint_with_single_expr_and_alias__plan0.sql | 436 ++--- ...single_expr_and_alias__plan0_optimized.sql | 6 +- ...multi_hop_through_scd_dimension__plan0.sql | 444 ++--- ...through_scd_dimension__plan0_optimized.sql | 22 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 410 ++--- ..._hop_to_scd_dimension__plan0_optimized.sql | 22 +- .../Postgres/test_multihop_node__plan0.sql | 602 +++--- .../test_multihop_node__plan0_optimized.sql | 10 +- ..._multiple_metrics_no_dimensions__plan0.sql | 704 +++---- ...metrics_no_dimensions__plan0_optimized.sql | 8 +- ..._constraint_with_reused_measure__plan0.sql | 670 +++---- ...t_with_reused_measure__plan0_optimized.sql | 20 +- ...aint_with_single_expr_and_alias__plan0.sql | 436 ++--- ...single_expr_and_alias__plan0_optimized.sql | 6 +- ...multi_hop_through_scd_dimension__plan0.sql | 444 ++--- ...through_scd_dimension__plan0_optimized.sql | 22 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 410 ++--- ..._hop_to_scd_dimension__plan0_optimized.sql | 22 +- .../Redshift/test_multihop_node__plan0.sql | 602 +++--- .../test_multihop_node__plan0_optimized.sql | 10 +- ..._multiple_metrics_no_dimensions__plan0.sql | 704 +++---- ...metrics_no_dimensions__plan0_optimized.sql | 8 +- ..._constraint_with_reused_measure__plan0.sql | 670 +++---- ...t_with_reused_measure__plan0_optimized.sql | 20 +- ...aint_with_single_expr_and_alias__plan0.sql | 436 ++--- ...single_expr_and_alias__plan0_optimized.sql | 6 +- ...multi_hop_through_scd_dimension__plan0.sql | 444 ++--- ...through_scd_dimension__plan0_optimized.sql | 22 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 410 ++--- ..._hop_to_scd_dimension__plan0_optimized.sql | 22 +- .../Snowflake/test_multihop_node__plan0.sql | 602 +++--- .../test_multihop_node__plan0_optimized.sql | 10 +- ..._multiple_metrics_no_dimensions__plan0.sql | 704 +++---- ...metrics_no_dimensions__plan0_optimized.sql | 8 +- ..._constraint_with_reused_measure__plan0.sql | 670 +++---- ...t_with_reused_measure__plan0_optimized.sql | 20 +- ...aint_with_single_expr_and_alias__plan0.sql | 436 ++--- ...single_expr_and_alias__plan0_optimized.sql | 6 +- ...multi_hop_through_scd_dimension__plan0.sql | 444 ++--- ...through_scd_dimension__plan0_optimized.sql | 22 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 410 ++--- ..._hop_to_scd_dimension__plan0_optimized.sql | 22 +- .../Trino/test_multihop_node__plan0.sql | 602 +++--- .../test_multihop_node__plan0_optimized.sql | 10 +- ..._multiple_metrics_no_dimensions__plan0.sql | 704 +++---- ...metrics_no_dimensions__plan0_optimized.sql | 8 +- ...ne_with_queried_time_constraint__plan0.sql | 440 ++--- ...eried_time_constraint__plan0_optimized.sql | 18 +- ...time_spine_with_time_constraint__plan0.sql | 410 ++--- ..._with_time_constraint__plan0_optimized.sql | 2 +- ..._join_to_time_spine_with_filter__plan0.sql | 444 ++--- ...ime_spine_with_filter__plan0_optimized.sql | 16 +- ..._time_spine_with_queried_filter__plan0.sql | 452 ++--- ...e_with_queried_filter__plan0_optimized.sql | 20 +- ...ne_with_queried_time_constraint__plan0.sql | 442 ++--- ...eried_time_constraint__plan0_optimized.sql | 18 +- ...time_spine_with_time_constraint__plan0.sql | 410 ++--- ..._with_time_constraint__plan0_optimized.sql | 2 +- ..._join_to_time_spine_with_filter__plan0.sql | 446 ++--- ...ime_spine_with_filter__plan0_optimized.sql | 16 +- ..._time_spine_with_queried_filter__plan0.sql | 456 ++--- ...e_with_queried_filter__plan0_optimized.sql | 20 +- ...ne_with_queried_time_constraint__plan0.sql | 442 ++--- ...eried_time_constraint__plan0_optimized.sql | 18 +- ...time_spine_with_time_constraint__plan0.sql | 410 ++--- ..._with_time_constraint__plan0_optimized.sql | 2 +- ..._join_to_time_spine_with_filter__plan0.sql | 446 ++--- ...ime_spine_with_filter__plan0_optimized.sql | 16 +- ..._time_spine_with_queried_filter__plan0.sql | 456 ++--- ...e_with_queried_filter__plan0_optimized.sql | 20 +- ...ne_with_queried_time_constraint__plan0.sql | 442 ++--- ...eried_time_constraint__plan0_optimized.sql | 18 +- ...time_spine_with_time_constraint__plan0.sql | 410 ++--- ..._with_time_constraint__plan0_optimized.sql | 2 +- ..._join_to_time_spine_with_filter__plan0.sql | 446 ++--- ...ime_spine_with_filter__plan0_optimized.sql | 16 +- ..._time_spine_with_queried_filter__plan0.sql | 456 ++--- ...e_with_queried_filter__plan0_optimized.sql | 20 +- ...ne_with_queried_time_constraint__plan0.sql | 442 ++--- ...eried_time_constraint__plan0_optimized.sql | 18 +- ...time_spine_with_time_constraint__plan0.sql | 410 ++--- ..._with_time_constraint__plan0_optimized.sql | 2 +- ..._join_to_time_spine_with_filter__plan0.sql | 446 ++--- ...ime_spine_with_filter__plan0_optimized.sql | 16 +- ..._time_spine_with_queried_filter__plan0.sql | 456 ++--- ...e_with_queried_filter__plan0_optimized.sql | 20 +- ...ne_with_queried_time_constraint__plan0.sql | 442 ++--- ...eried_time_constraint__plan0_optimized.sql | 18 +- ...time_spine_with_time_constraint__plan0.sql | 410 ++--- ..._with_time_constraint__plan0_optimized.sql | 2 +- ..._join_to_time_spine_with_filter__plan0.sql | 446 ++--- ...ime_spine_with_filter__plan0_optimized.sql | 16 +- ..._time_spine_with_queried_filter__plan0.sql | 456 ++--- ...e_with_queried_filter__plan0_optimized.sql | 20 +- 402 files changed, 53890 insertions(+), 53890 deletions(-) diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_time_constraint__plan0.sql index 1a1dcdd800..57dabba23b 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_time_constraint__plan0.sql @@ -1,116 +1,116 @@ -- Compute Metrics via Expressions SELECT - subq_21.visit__referrer_id - , CAST(subq_21.buys AS FLOAT64) / CAST(NULLIF(subq_21.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate + subq_17.visit__referrer_id + , CAST(subq_17.buys AS FLOAT64) / CAST(NULLIF(subq_17.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) AS visit__referrer_id - , MAX(subq_9.visits) AS visits - , MAX(subq_20.buys) AS buys + COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) AS visit__referrer_id + , MAX(subq_5.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.visit__referrer_id - , SUM(subq_8.visits) AS visits + subq_4.visit__referrer_id + , SUM(subq_4.visits) AS visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.visit__referrer_id - , subq_7.visits + subq_3.visit__referrer_id + , subq_3.visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT - subq_6.visit__referrer_id - , subq_6.visits + subq_2.visit__referrer_id + , subq_2.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.visit__ds__day - , subq_5.visit__ds__week - , subq_5.visit__ds__month - , subq_5.visit__ds__quarter - , subq_5.visit__ds__year - , subq_5.visit__ds__extract_year - , subq_5.visit__ds__extract_quarter - , subq_5.visit__ds__extract_month - , subq_5.visit__ds__extract_day - , subq_5.visit__ds__extract_dow - , subq_5.visit__ds__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.user - , subq_5.session - , subq_5.visit__user - , subq_5.visit__session - , subq_5.referrer_id - , subq_5.visit__referrer_id - , subq_5.visits - , subq_5.visitors + 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.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -145,166 +145,166 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_2 + ) subq_3 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 + ) subq_4 GROUP BY visit__referrer_id - ) subq_9 + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_19.visit__referrer_id - , SUM(subq_19.buys) AS buys + subq_15.visit__referrer_id + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id'] SELECT - subq_18.visit__referrer_id - , subq_18.buys + subq_14.visit__referrer_id + , subq_14.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_17.ds__day - , subq_17.user - , subq_17.visit__referrer_id - , subq_17.buys - , subq_17.visits + subq_13.ds__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_13.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_13.visit__referrer_id) OVER ( + , first_value(subq_9.visit__referrer_id) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_13.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_13.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_16.mf_internal_uuid AS mf_internal_uuid - , subq_16.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user'] SELECT - subq_12.ds__day - , subq_12.user - , subq_12.visit__referrer_id - , subq_12.visits + subq_8.ds__day + , subq_8.user + , subq_8.visit__referrer_id + , subq_8.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.visit__ds__day - , subq_11.visit__ds__week - , subq_11.visit__ds__month - , subq_11.visit__ds__quarter - , subq_11.visit__ds__year - , subq_11.visit__ds__extract_year - , subq_11.visit__ds__extract_quarter - , subq_11.visit__ds__extract_month - , subq_11.visit__ds__extract_day - , subq_11.visit__ds__extract_dow - , subq_11.visit__ds__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session - , subq_11.visit__user - , subq_11.visit__session - , subq_11.referrer_id - , subq_11.visit__referrer_id - , subq_11.visits - , subq_11.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__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.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors 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.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__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.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + 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.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__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.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -339,96 +339,96 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_12 - ) subq_13 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.buy__ds__day - , subq_15.buy__ds__week - , subq_15.buy__ds__month - , subq_15.buy__ds__quarter - , subq_15.buy__ds__year - , subq_15.buy__ds__extract_year - , subq_15.buy__ds__extract_quarter - , subq_15.buy__ds__extract_month - , subq_15.buy__ds__extract_day - , subq_15.buy__ds__extract_dow - , subq_15.buy__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.user - , subq_15.session_id - , subq_15.buy__user - , subq_15.buy__session_id - , subq_15.buys - , subq_15.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , GENERATE_UUID() AS mf_internal_uuid 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.buy__ds__day - , subq_14.buy__ds__week - , subq_14.buy__ds__month - , subq_14.buy__ds__quarter - , subq_14.buy__ds__year - , subq_14.buy__ds__extract_year - , subq_14.buy__ds__extract_quarter - , subq_14.buy__ds__extract_month - , subq_14.buy__ds__extract_day - , subq_14.buy__ds__extract_dow - , subq_14.buy__ds__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.user - , subq_14.session_id - , subq_14.buy__user - , subq_14.buy__session_id - , subq_14.buys - , subq_14.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -461,23 +461,23 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_13.user = subq_16.user + subq_9.user = subq_12.user ) AND ( - (subq_13.ds__day <= subq_16.ds__day) + (subq_9.ds__day <= subq_12.ds__day) ) - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY visit__referrer_id - ) subq_20 + ) subq_16 ON - subq_9.visit__referrer_id = subq_20.visit__referrer_id + subq_5.visit__referrer_id = subq_16.visit__referrer_id GROUP BY visit__referrer_id -) subq_21 +) subq_17 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_time_constraint__plan0_optimized.sql index 5c959f1dd8..5d3501c2d0 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_time_constraint__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) AS visit__referrer_id - , MAX(subq_31.visits) AS visits - , MAX(subq_42.buys) AS buys + COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) AS visit__referrer_id + , MAX(subq_23.visits) AS visits + , MAX(subq_34.buys) AS buys FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -24,11 +24,11 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATETIME_TRUNC(ds, day) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_29 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY visit__referrer_id - ) subq_31 + ) subq_23 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'visit__referrer_id'] @@ -39,40 +39,40 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_35.visits) OVER ( + first_value(subq_27.visits) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_35.visit__referrer_id) OVER ( + , first_value(subq_27.visit__referrer_id) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_35.ds__day) OVER ( + , first_value(subq_27.ds__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_35.user) OVER ( + , first_value(subq_27.user) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_38.mf_internal_uuid AS mf_internal_uuid - , subq_38.buys AS buys + , subq_30.mf_internal_uuid AS mf_internal_uuid + , subq_30.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -85,7 +85,7 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATETIME_TRUNC(ds, day) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_35 + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -96,19 +96,19 @@ FROM ( , 1 AS buys , GENERATE_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_38 + ) subq_30 ON ( - subq_35.user = subq_38.user + subq_27.user = subq_30.user ) AND ( - (subq_35.ds__day <= subq_38.ds__day) + (subq_27.ds__day <= subq_30.ds__day) ) - ) subq_39 + ) subq_31 GROUP BY visit__referrer_id - ) subq_42 + ) subq_34 ON - subq_31.visit__referrer_id = subq_42.visit__referrer_id + subq_23.visit__referrer_id = subq_34.visit__referrer_id GROUP BY visit__referrer_id -) subq_43 +) subq_35 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window_and_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window_and_time_constraint__plan0.sql index 1acc95787d..cd081ab645 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window_and_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window_and_time_constraint__plan0.sql @@ -1,121 +1,121 @@ -- Compute Metrics via Expressions SELECT - subq_21.metric_time__day - , subq_21.visit__referrer_id - , CAST(subq_21.buys AS FLOAT64) / CAST(NULLIF(subq_21.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days + subq_17.metric_time__day + , subq_17.visit__referrer_id + , CAST(subq_17.buys AS FLOAT64) / CAST(NULLIF(subq_17.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) AS visit__referrer_id - , MAX(subq_9.visits) AS visits - , MAX(subq_20.buys) AS buys + COALESCE(subq_5.metric_time__day, subq_16.metric_time__day) AS metric_time__day + , COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) AS visit__referrer_id + , MAX(subq_5.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , subq_8.visit__referrer_id - , SUM(subq_8.visits) AS visits + subq_4.metric_time__day + , subq_4.visit__referrer_id + , SUM(subq_4.visits) AS visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.visit__referrer_id - , subq_7.visits + subq_3.metric_time__day + , subq_3.visit__referrer_id + , subq_3.visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.visit__referrer_id - , subq_6.visits + subq_2.metric_time__day + , subq_2.visit__referrer_id + , subq_2.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.visit__ds__day - , subq_5.visit__ds__week - , subq_5.visit__ds__month - , subq_5.visit__ds__quarter - , subq_5.visit__ds__year - , subq_5.visit__ds__extract_year - , subq_5.visit__ds__extract_quarter - , subq_5.visit__ds__extract_month - , subq_5.visit__ds__extract_day - , subq_5.visit__ds__extract_dow - , subq_5.visit__ds__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.user - , subq_5.session - , subq_5.visit__user - , subq_5.visit__session - , subq_5.referrer_id - , subq_5.visit__referrer_id - , subq_5.visits - , subq_5.visitors + 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.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -150,179 +150,179 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_2 + ) subq_3 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 + ) subq_4 GROUP BY metric_time__day , visit__referrer_id - ) subq_9 + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_19.metric_time__day - , subq_19.visit__referrer_id - , SUM(subq_19.buys) AS buys + subq_15.metric_time__day + , subq_15.visit__referrer_id + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.visit__referrer_id - , subq_18.buys + subq_14.metric_time__day + , subq_14.visit__referrer_id + , subq_14.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_17.ds__day - , subq_17.metric_time__day - , subq_17.user - , subq_17.visit__referrer_id - , subq_17.buys - , subq_17.visits + subq_13.ds__day + , subq_13.metric_time__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_13.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_13.visit__referrer_id) OVER ( + , first_value(subq_9.visit__referrer_id) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_13.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_13.metric_time__day) OVER ( + , first_value(subq_9.metric_time__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , first_value(subq_13.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_16.mf_internal_uuid AS mf_internal_uuid - , subq_16.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] SELECT - subq_12.ds__day - , subq_12.metric_time__day - , subq_12.user - , subq_12.visit__referrer_id - , subq_12.visits + subq_8.ds__day + , subq_8.metric_time__day + , subq_8.user + , subq_8.visit__referrer_id + , subq_8.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.visit__ds__day - , subq_11.visit__ds__week - , subq_11.visit__ds__month - , subq_11.visit__ds__quarter - , subq_11.visit__ds__year - , subq_11.visit__ds__extract_year - , subq_11.visit__ds__extract_quarter - , subq_11.visit__ds__extract_month - , subq_11.visit__ds__extract_day - , subq_11.visit__ds__extract_dow - , subq_11.visit__ds__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session - , subq_11.visit__user - , subq_11.visit__session - , subq_11.referrer_id - , subq_11.visit__referrer_id - , subq_11.visits - , subq_11.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__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.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors 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.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__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.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + 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.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__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.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -357,96 +357,96 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_12 - ) subq_13 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.buy__ds__day - , subq_15.buy__ds__week - , subq_15.buy__ds__month - , subq_15.buy__ds__quarter - , subq_15.buy__ds__year - , subq_15.buy__ds__extract_year - , subq_15.buy__ds__extract_quarter - , subq_15.buy__ds__extract_month - , subq_15.buy__ds__extract_day - , subq_15.buy__ds__extract_dow - , subq_15.buy__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.user - , subq_15.session_id - , subq_15.buy__user - , subq_15.buy__session_id - , subq_15.buys - , subq_15.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , GENERATE_UUID() AS mf_internal_uuid 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.buy__ds__day - , subq_14.buy__ds__week - , subq_14.buy__ds__month - , subq_14.buy__ds__quarter - , subq_14.buy__ds__year - , subq_14.buy__ds__extract_year - , subq_14.buy__ds__extract_quarter - , subq_14.buy__ds__extract_month - , subq_14.buy__ds__extract_day - , subq_14.buy__ds__extract_dow - , subq_14.buy__ds__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.user - , subq_14.session_id - , subq_14.buy__user - , subq_14.buy__session_id - , subq_14.buys - , subq_14.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -479,33 +479,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_13.user = subq_16.user + subq_9.user = subq_12.user ) AND ( ( - subq_13.ds__day <= subq_16.ds__day + subq_9.ds__day <= subq_12.ds__day ) AND ( - subq_13.ds__day > DATE_SUB(CAST(subq_16.ds__day AS DATETIME), INTERVAL 7 day) + subq_9.ds__day > DATE_SUB(CAST(subq_12.ds__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY metric_time__day , visit__referrer_id - ) subq_20 + ) subq_16 ON ( - subq_9.visit__referrer_id = subq_20.visit__referrer_id + subq_5.visit__referrer_id = subq_16.visit__referrer_id ) AND ( - subq_9.metric_time__day = subq_20.metric_time__day + subq_5.metric_time__day = subq_16.metric_time__day ) GROUP BY metric_time__day , visit__referrer_id -) subq_21 +) subq_17 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql index 55921d6500..e2be1f8869 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.metric_time__day, subq_42.metric_time__day) AS metric_time__day - , COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) AS visit__referrer_id - , MAX(subq_31.visits) AS visits - , MAX(subq_42.buys) AS buys + COALESCE(subq_23.metric_time__day, subq_34.metric_time__day) AS metric_time__day + , COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) AS visit__referrer_id + , MAX(subq_23.visits) AS visits + , MAX(subq_34.buys) AS buys FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -28,12 +28,12 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATETIME_TRUNC(ds, day) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_29 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day , visit__referrer_id - ) subq_31 + ) subq_23 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -45,48 +45,48 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_35.visits) OVER ( + first_value(subq_27.visits) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_35.visit__referrer_id) OVER ( + , first_value(subq_27.visit__referrer_id) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_35.ds__day) OVER ( + , first_value(subq_27.ds__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_35.metric_time__day) OVER ( + , first_value(subq_27.metric_time__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , first_value(subq_35.user) OVER ( + , first_value(subq_27.user) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_38.mf_internal_uuid AS mf_internal_uuid - , subq_38.buys AS buys + , subq_30.mf_internal_uuid AS mf_internal_uuid + , subq_30.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -100,7 +100,7 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATETIME_TRUNC(ds, day) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_35 + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -111,29 +111,29 @@ FROM ( , 1 AS buys , GENERATE_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_38 + ) subq_30 ON ( - subq_35.user = subq_38.user + subq_27.user = subq_30.user ) AND ( ( - subq_35.ds__day <= subq_38.ds__day + subq_27.ds__day <= subq_30.ds__day ) AND ( - subq_35.ds__day > DATE_SUB(CAST(subq_38.ds__day AS DATETIME), INTERVAL 7 day) + subq_27.ds__day > DATE_SUB(CAST(subq_30.ds__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_39 + ) subq_31 GROUP BY metric_time__day , visit__referrer_id - ) subq_42 + ) subq_34 ON ( - subq_31.visit__referrer_id = subq_42.visit__referrer_id + subq_23.visit__referrer_id = subq_34.visit__referrer_id ) AND ( - subq_31.metric_time__day = subq_42.metric_time__day + subq_23.metric_time__day = subq_34.metric_time__day ) GROUP BY metric_time__day , visit__referrer_id -) subq_43 +) subq_35 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_time_constraint__plan0.sql index abd7eb5465..d8211a8ee7 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_time_constraint__plan0.sql @@ -1,116 +1,116 @@ -- Compute Metrics via Expressions SELECT - subq_21.visit__referrer_id - , CAST(subq_21.buys AS DOUBLE) / CAST(NULLIF(subq_21.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate + subq_17.visit__referrer_id + , CAST(subq_17.buys AS DOUBLE) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) AS visit__referrer_id - , MAX(subq_9.visits) AS visits - , MAX(subq_20.buys) AS buys + COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) AS visit__referrer_id + , MAX(subq_5.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.visit__referrer_id - , SUM(subq_8.visits) AS visits + subq_4.visit__referrer_id + , SUM(subq_4.visits) AS visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.visit__referrer_id - , subq_7.visits + subq_3.visit__referrer_id + , subq_3.visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT - subq_6.visit__referrer_id - , subq_6.visits + subq_2.visit__referrer_id + , subq_2.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.visit__ds__day - , subq_5.visit__ds__week - , subq_5.visit__ds__month - , subq_5.visit__ds__quarter - , subq_5.visit__ds__year - , subq_5.visit__ds__extract_year - , subq_5.visit__ds__extract_quarter - , subq_5.visit__ds__extract_month - , subq_5.visit__ds__extract_day - , subq_5.visit__ds__extract_dow - , subq_5.visit__ds__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.user - , subq_5.session - , subq_5.visit__user - , subq_5.visit__session - , subq_5.referrer_id - , subq_5.visit__referrer_id - , subq_5.visits - , subq_5.visitors + 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.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -145,166 +145,166 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_2 + ) subq_3 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 + ) subq_4 GROUP BY - subq_8.visit__referrer_id - ) subq_9 + subq_4.visit__referrer_id + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_19.visit__referrer_id - , SUM(subq_19.buys) AS buys + subq_15.visit__referrer_id + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id'] SELECT - subq_18.visit__referrer_id - , subq_18.buys + subq_14.visit__referrer_id + , subq_14.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_17.ds__day - , subq_17.user - , subq_17.visit__referrer_id - , subq_17.buys - , subq_17.visits + subq_13.ds__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_13.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_13.visit__referrer_id) OVER ( + , first_value(subq_9.visit__referrer_id) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_13.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_13.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_16.mf_internal_uuid AS mf_internal_uuid - , subq_16.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user'] SELECT - subq_12.ds__day - , subq_12.user - , subq_12.visit__referrer_id - , subq_12.visits + subq_8.ds__day + , subq_8.user + , subq_8.visit__referrer_id + , subq_8.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.visit__ds__day - , subq_11.visit__ds__week - , subq_11.visit__ds__month - , subq_11.visit__ds__quarter - , subq_11.visit__ds__year - , subq_11.visit__ds__extract_year - , subq_11.visit__ds__extract_quarter - , subq_11.visit__ds__extract_month - , subq_11.visit__ds__extract_day - , subq_11.visit__ds__extract_dow - , subq_11.visit__ds__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session - , subq_11.visit__user - , subq_11.visit__session - , subq_11.referrer_id - , subq_11.visit__referrer_id - , subq_11.visits - , subq_11.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__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.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors 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.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__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.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + 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.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__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.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -339,96 +339,96 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_12 - ) subq_13 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.buy__ds__day - , subq_15.buy__ds__week - , subq_15.buy__ds__month - , subq_15.buy__ds__quarter - , subq_15.buy__ds__year - , subq_15.buy__ds__extract_year - , subq_15.buy__ds__extract_quarter - , subq_15.buy__ds__extract_month - , subq_15.buy__ds__extract_day - , subq_15.buy__ds__extract_dow - , subq_15.buy__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.user - , subq_15.session_id - , subq_15.buy__user - , subq_15.buy__session_id - , subq_15.buys - , subq_15.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , UUID() AS mf_internal_uuid 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.buy__ds__day - , subq_14.buy__ds__week - , subq_14.buy__ds__month - , subq_14.buy__ds__quarter - , subq_14.buy__ds__year - , subq_14.buy__ds__extract_year - , subq_14.buy__ds__extract_quarter - , subq_14.buy__ds__extract_month - , subq_14.buy__ds__extract_day - , subq_14.buy__ds__extract_dow - , subq_14.buy__ds__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.user - , subq_14.session_id - , subq_14.buy__user - , subq_14.buy__session_id - , subq_14.buys - , subq_14.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -461,23 +461,23 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_13.user = subq_16.user + subq_9.user = subq_12.user ) AND ( - (subq_13.ds__day <= subq_16.ds__day) + (subq_9.ds__day <= subq_12.ds__day) ) - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY - subq_19.visit__referrer_id - ) subq_20 + subq_15.visit__referrer_id + ) subq_16 ON - subq_9.visit__referrer_id = subq_20.visit__referrer_id + subq_5.visit__referrer_id = subq_16.visit__referrer_id GROUP BY - COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) -) subq_21 + COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) +) subq_17 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_time_constraint__plan0_optimized.sql index 64a92a5f53..58747cc7ab 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_time_constraint__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) AS visit__referrer_id - , MAX(subq_31.visits) AS visits - , MAX(subq_42.buys) AS buys + COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) AS visit__referrer_id + , MAX(subq_23.visits) AS visits + , MAX(subq_34.buys) AS buys FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -24,11 +24,11 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_29 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY visit__referrer_id - ) subq_31 + ) subq_23 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'visit__referrer_id'] @@ -39,40 +39,40 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_35.visits) OVER ( + first_value(subq_27.visits) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_35.visit__referrer_id) OVER ( + , first_value(subq_27.visit__referrer_id) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_35.ds__day) OVER ( + , first_value(subq_27.ds__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_35.user) OVER ( + , first_value(subq_27.user) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_38.mf_internal_uuid AS mf_internal_uuid - , subq_38.buys AS buys + , subq_30.mf_internal_uuid AS mf_internal_uuid + , subq_30.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -85,7 +85,7 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_35 + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -96,19 +96,19 @@ FROM ( , 1 AS buys , UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_38 + ) subq_30 ON ( - subq_35.user = subq_38.user + subq_27.user = subq_30.user ) AND ( - (subq_35.ds__day <= subq_38.ds__day) + (subq_27.ds__day <= subq_30.ds__day) ) - ) subq_39 + ) subq_31 GROUP BY visit__referrer_id - ) subq_42 + ) subq_34 ON - subq_31.visit__referrer_id = subq_42.visit__referrer_id + subq_23.visit__referrer_id = subq_34.visit__referrer_id GROUP BY - COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) -) subq_43 + COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) +) subq_35 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window_and_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window_and_time_constraint__plan0.sql index 334aa030cf..bb36d4e1ff 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window_and_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window_and_time_constraint__plan0.sql @@ -1,121 +1,121 @@ -- Compute Metrics via Expressions SELECT - subq_21.metric_time__day - , subq_21.visit__referrer_id - , CAST(subq_21.buys AS DOUBLE) / CAST(NULLIF(subq_21.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + subq_17.metric_time__day + , subq_17.visit__referrer_id + , CAST(subq_17.buys AS DOUBLE) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) AS visit__referrer_id - , MAX(subq_9.visits) AS visits - , MAX(subq_20.buys) AS buys + COALESCE(subq_5.metric_time__day, subq_16.metric_time__day) AS metric_time__day + , COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) AS visit__referrer_id + , MAX(subq_5.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , subq_8.visit__referrer_id - , SUM(subq_8.visits) AS visits + subq_4.metric_time__day + , subq_4.visit__referrer_id + , SUM(subq_4.visits) AS visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.visit__referrer_id - , subq_7.visits + subq_3.metric_time__day + , subq_3.visit__referrer_id + , subq_3.visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.visit__referrer_id - , subq_6.visits + subq_2.metric_time__day + , subq_2.visit__referrer_id + , subq_2.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.visit__ds__day - , subq_5.visit__ds__week - , subq_5.visit__ds__month - , subq_5.visit__ds__quarter - , subq_5.visit__ds__year - , subq_5.visit__ds__extract_year - , subq_5.visit__ds__extract_quarter - , subq_5.visit__ds__extract_month - , subq_5.visit__ds__extract_day - , subq_5.visit__ds__extract_dow - , subq_5.visit__ds__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.user - , subq_5.session - , subq_5.visit__user - , subq_5.visit__session - , subq_5.referrer_id - , subq_5.visit__referrer_id - , subq_5.visits - , subq_5.visitors + 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.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -150,179 +150,179 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_2 + ) subq_3 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 + ) subq_4 GROUP BY - subq_8.metric_time__day - , subq_8.visit__referrer_id - ) subq_9 + subq_4.metric_time__day + , subq_4.visit__referrer_id + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_19.metric_time__day - , subq_19.visit__referrer_id - , SUM(subq_19.buys) AS buys + subq_15.metric_time__day + , subq_15.visit__referrer_id + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.visit__referrer_id - , subq_18.buys + subq_14.metric_time__day + , subq_14.visit__referrer_id + , subq_14.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_17.ds__day - , subq_17.metric_time__day - , subq_17.user - , subq_17.visit__referrer_id - , subq_17.buys - , subq_17.visits + subq_13.ds__day + , subq_13.metric_time__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_13.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_13.visit__referrer_id) OVER ( + , first_value(subq_9.visit__referrer_id) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_13.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_13.metric_time__day) OVER ( + , first_value(subq_9.metric_time__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , first_value(subq_13.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_16.mf_internal_uuid AS mf_internal_uuid - , subq_16.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] SELECT - subq_12.ds__day - , subq_12.metric_time__day - , subq_12.user - , subq_12.visit__referrer_id - , subq_12.visits + subq_8.ds__day + , subq_8.metric_time__day + , subq_8.user + , subq_8.visit__referrer_id + , subq_8.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.visit__ds__day - , subq_11.visit__ds__week - , subq_11.visit__ds__month - , subq_11.visit__ds__quarter - , subq_11.visit__ds__year - , subq_11.visit__ds__extract_year - , subq_11.visit__ds__extract_quarter - , subq_11.visit__ds__extract_month - , subq_11.visit__ds__extract_day - , subq_11.visit__ds__extract_dow - , subq_11.visit__ds__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session - , subq_11.visit__user - , subq_11.visit__session - , subq_11.referrer_id - , subq_11.visit__referrer_id - , subq_11.visits - , subq_11.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__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.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors 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.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__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.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + 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.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__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.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -357,96 +357,96 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_12 - ) subq_13 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.buy__ds__day - , subq_15.buy__ds__week - , subq_15.buy__ds__month - , subq_15.buy__ds__quarter - , subq_15.buy__ds__year - , subq_15.buy__ds__extract_year - , subq_15.buy__ds__extract_quarter - , subq_15.buy__ds__extract_month - , subq_15.buy__ds__extract_day - , subq_15.buy__ds__extract_dow - , subq_15.buy__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.user - , subq_15.session_id - , subq_15.buy__user - , subq_15.buy__session_id - , subq_15.buys - , subq_15.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , UUID() AS mf_internal_uuid 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.buy__ds__day - , subq_14.buy__ds__week - , subq_14.buy__ds__month - , subq_14.buy__ds__quarter - , subq_14.buy__ds__year - , subq_14.buy__ds__extract_year - , subq_14.buy__ds__extract_quarter - , subq_14.buy__ds__extract_month - , subq_14.buy__ds__extract_day - , subq_14.buy__ds__extract_dow - , subq_14.buy__ds__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.user - , subq_14.session_id - , subq_14.buy__user - , subq_14.buy__session_id - , subq_14.buys - , subq_14.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -479,33 +479,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_13.user = subq_16.user + subq_9.user = subq_12.user ) AND ( ( - subq_13.ds__day <= subq_16.ds__day + subq_9.ds__day <= subq_12.ds__day ) AND ( - subq_13.ds__day > DATEADD(day, -7, subq_16.ds__day) + subq_9.ds__day > DATEADD(day, -7, subq_12.ds__day) ) ) - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY - subq_19.metric_time__day - , subq_19.visit__referrer_id - ) subq_20 + subq_15.metric_time__day + , subq_15.visit__referrer_id + ) subq_16 ON ( - subq_9.visit__referrer_id = subq_20.visit__referrer_id + subq_5.visit__referrer_id = subq_16.visit__referrer_id ) AND ( - subq_9.metric_time__day = subq_20.metric_time__day + subq_5.metric_time__day = subq_16.metric_time__day ) GROUP BY - COALESCE(subq_9.metric_time__day, subq_20.metric_time__day) - , COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) -) subq_21 + COALESCE(subq_5.metric_time__day, subq_16.metric_time__day) + , COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) +) subq_17 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql index 42ba64d283..33e4d63ee7 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.metric_time__day, subq_42.metric_time__day) AS metric_time__day - , COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) AS visit__referrer_id - , MAX(subq_31.visits) AS visits - , MAX(subq_42.buys) AS buys + COALESCE(subq_23.metric_time__day, subq_34.metric_time__day) AS metric_time__day + , COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) AS visit__referrer_id + , MAX(subq_23.visits) AS visits + , MAX(subq_34.buys) AS buys FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -28,12 +28,12 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_29 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day , visit__referrer_id - ) subq_31 + ) subq_23 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -45,48 +45,48 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_35.visits) OVER ( + first_value(subq_27.visits) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_35.visit__referrer_id) OVER ( + , first_value(subq_27.visit__referrer_id) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_35.ds__day) OVER ( + , first_value(subq_27.ds__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_35.metric_time__day) OVER ( + , first_value(subq_27.metric_time__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , first_value(subq_35.user) OVER ( + , first_value(subq_27.user) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_38.mf_internal_uuid AS mf_internal_uuid - , subq_38.buys AS buys + , subq_30.mf_internal_uuid AS mf_internal_uuid + , subq_30.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -100,7 +100,7 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_35 + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -111,29 +111,29 @@ FROM ( , 1 AS buys , UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_38 + ) subq_30 ON ( - subq_35.user = subq_38.user + subq_27.user = subq_30.user ) AND ( ( - subq_35.ds__day <= subq_38.ds__day + subq_27.ds__day <= subq_30.ds__day ) AND ( - subq_35.ds__day > DATEADD(day, -7, subq_38.ds__day) + subq_27.ds__day > DATEADD(day, -7, subq_30.ds__day) ) ) - ) subq_39 + ) subq_31 GROUP BY metric_time__day , visit__referrer_id - ) subq_42 + ) subq_34 ON ( - subq_31.visit__referrer_id = subq_42.visit__referrer_id + subq_23.visit__referrer_id = subq_34.visit__referrer_id ) AND ( - subq_31.metric_time__day = subq_42.metric_time__day + subq_23.metric_time__day = subq_34.metric_time__day ) GROUP BY - COALESCE(subq_31.metric_time__day, subq_42.metric_time__day) - , COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) -) subq_43 + COALESCE(subq_23.metric_time__day, subq_34.metric_time__day) + , COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) +) subq_35 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_time_constraint__plan0.sql index f41b943ee9..1457323862 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_time_constraint__plan0.sql @@ -1,116 +1,116 @@ -- Compute Metrics via Expressions SELECT - subq_21.visit__referrer_id - , CAST(subq_21.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_21.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate + subq_17.visit__referrer_id + , CAST(subq_17.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) AS visit__referrer_id - , MAX(subq_9.visits) AS visits - , MAX(subq_20.buys) AS buys + COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) AS visit__referrer_id + , MAX(subq_5.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.visit__referrer_id - , SUM(subq_8.visits) AS visits + subq_4.visit__referrer_id + , SUM(subq_4.visits) AS visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.visit__referrer_id - , subq_7.visits + subq_3.visit__referrer_id + , subq_3.visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT - subq_6.visit__referrer_id - , subq_6.visits + subq_2.visit__referrer_id + , subq_2.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.visit__ds__day - , subq_5.visit__ds__week - , subq_5.visit__ds__month - , subq_5.visit__ds__quarter - , subq_5.visit__ds__year - , subq_5.visit__ds__extract_year - , subq_5.visit__ds__extract_quarter - , subq_5.visit__ds__extract_month - , subq_5.visit__ds__extract_day - , subq_5.visit__ds__extract_dow - , subq_5.visit__ds__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.user - , subq_5.session - , subq_5.visit__user - , subq_5.visit__session - , subq_5.referrer_id - , subq_5.visit__referrer_id - , subq_5.visits - , subq_5.visitors + 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.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -145,166 +145,166 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_2 + ) subq_3 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 + ) subq_4 GROUP BY - subq_8.visit__referrer_id - ) subq_9 + subq_4.visit__referrer_id + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_19.visit__referrer_id - , SUM(subq_19.buys) AS buys + subq_15.visit__referrer_id + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id'] SELECT - subq_18.visit__referrer_id - , subq_18.buys + subq_14.visit__referrer_id + , subq_14.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_17.ds__day - , subq_17.user - , subq_17.visit__referrer_id - , subq_17.buys - , subq_17.visits + subq_13.ds__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_13.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_13.visit__referrer_id) OVER ( + , first_value(subq_9.visit__referrer_id) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_13.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_13.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_16.mf_internal_uuid AS mf_internal_uuid - , subq_16.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user'] SELECT - subq_12.ds__day - , subq_12.user - , subq_12.visit__referrer_id - , subq_12.visits + subq_8.ds__day + , subq_8.user + , subq_8.visit__referrer_id + , subq_8.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.visit__ds__day - , subq_11.visit__ds__week - , subq_11.visit__ds__month - , subq_11.visit__ds__quarter - , subq_11.visit__ds__year - , subq_11.visit__ds__extract_year - , subq_11.visit__ds__extract_quarter - , subq_11.visit__ds__extract_month - , subq_11.visit__ds__extract_day - , subq_11.visit__ds__extract_dow - , subq_11.visit__ds__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session - , subq_11.visit__user - , subq_11.visit__session - , subq_11.referrer_id - , subq_11.visit__referrer_id - , subq_11.visits - , subq_11.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__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.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors 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.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__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.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + 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.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__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.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -339,96 +339,96 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_12 - ) subq_13 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.buy__ds__day - , subq_15.buy__ds__week - , subq_15.buy__ds__month - , subq_15.buy__ds__quarter - , subq_15.buy__ds__year - , subq_15.buy__ds__extract_year - , subq_15.buy__ds__extract_quarter - , subq_15.buy__ds__extract_month - , subq_15.buy__ds__extract_day - , subq_15.buy__ds__extract_dow - , subq_15.buy__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.user - , subq_15.session_id - , subq_15.buy__user - , subq_15.buy__session_id - , subq_15.buys - , subq_15.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , GEN_RANDOM_UUID() AS mf_internal_uuid 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.buy__ds__day - , subq_14.buy__ds__week - , subq_14.buy__ds__month - , subq_14.buy__ds__quarter - , subq_14.buy__ds__year - , subq_14.buy__ds__extract_year - , subq_14.buy__ds__extract_quarter - , subq_14.buy__ds__extract_month - , subq_14.buy__ds__extract_day - , subq_14.buy__ds__extract_dow - , subq_14.buy__ds__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.user - , subq_14.session_id - , subq_14.buy__user - , subq_14.buy__session_id - , subq_14.buys - , subq_14.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -461,23 +461,23 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_13.user = subq_16.user + subq_9.user = subq_12.user ) AND ( - (subq_13.ds__day <= subq_16.ds__day) + (subq_9.ds__day <= subq_12.ds__day) ) - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY - subq_19.visit__referrer_id - ) subq_20 + subq_15.visit__referrer_id + ) subq_16 ON - subq_9.visit__referrer_id = subq_20.visit__referrer_id + subq_5.visit__referrer_id = subq_16.visit__referrer_id GROUP BY - COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) -) subq_21 + COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) +) subq_17 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_time_constraint__plan0_optimized.sql index 090077c02b..8acf442e1e 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_time_constraint__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) AS visit__referrer_id - , MAX(subq_31.visits) AS visits - , MAX(subq_42.buys) AS buys + COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) AS visit__referrer_id + , MAX(subq_23.visits) AS visits + , MAX(subq_34.buys) AS buys FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -24,11 +24,11 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_29 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY visit__referrer_id - ) subq_31 + ) subq_23 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'visit__referrer_id'] @@ -39,40 +39,40 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_35.visits) OVER ( + first_value(subq_27.visits) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_35.visit__referrer_id) OVER ( + , first_value(subq_27.visit__referrer_id) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_35.ds__day) OVER ( + , first_value(subq_27.ds__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_35.user) OVER ( + , first_value(subq_27.user) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_38.mf_internal_uuid AS mf_internal_uuid - , subq_38.buys AS buys + , subq_30.mf_internal_uuid AS mf_internal_uuid + , subq_30.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -85,7 +85,7 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_35 + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -96,19 +96,19 @@ FROM ( , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_38 + ) subq_30 ON ( - subq_35.user = subq_38.user + subq_27.user = subq_30.user ) AND ( - (subq_35.ds__day <= subq_38.ds__day) + (subq_27.ds__day <= subq_30.ds__day) ) - ) subq_39 + ) subq_31 GROUP BY visit__referrer_id - ) subq_42 + ) subq_34 ON - subq_31.visit__referrer_id = subq_42.visit__referrer_id + subq_23.visit__referrer_id = subq_34.visit__referrer_id GROUP BY - COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) -) subq_43 + COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) +) subq_35 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window_and_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window_and_time_constraint__plan0.sql index df75c7f9fb..cb8b95232a 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window_and_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window_and_time_constraint__plan0.sql @@ -1,121 +1,121 @@ -- Compute Metrics via Expressions SELECT - subq_21.metric_time__day - , subq_21.visit__referrer_id - , CAST(subq_21.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_21.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + subq_17.metric_time__day + , subq_17.visit__referrer_id + , CAST(subq_17.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) AS visit__referrer_id - , MAX(subq_9.visits) AS visits - , MAX(subq_20.buys) AS buys + COALESCE(subq_5.metric_time__day, subq_16.metric_time__day) AS metric_time__day + , COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) AS visit__referrer_id + , MAX(subq_5.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , subq_8.visit__referrer_id - , SUM(subq_8.visits) AS visits + subq_4.metric_time__day + , subq_4.visit__referrer_id + , SUM(subq_4.visits) AS visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.visit__referrer_id - , subq_7.visits + subq_3.metric_time__day + , subq_3.visit__referrer_id + , subq_3.visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.visit__referrer_id - , subq_6.visits + subq_2.metric_time__day + , subq_2.visit__referrer_id + , subq_2.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.visit__ds__day - , subq_5.visit__ds__week - , subq_5.visit__ds__month - , subq_5.visit__ds__quarter - , subq_5.visit__ds__year - , subq_5.visit__ds__extract_year - , subq_5.visit__ds__extract_quarter - , subq_5.visit__ds__extract_month - , subq_5.visit__ds__extract_day - , subq_5.visit__ds__extract_dow - , subq_5.visit__ds__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.user - , subq_5.session - , subq_5.visit__user - , subq_5.visit__session - , subq_5.referrer_id - , subq_5.visit__referrer_id - , subq_5.visits - , subq_5.visitors + 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.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -150,179 +150,179 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_2 + ) subq_3 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 + ) subq_4 GROUP BY - subq_8.metric_time__day - , subq_8.visit__referrer_id - ) subq_9 + subq_4.metric_time__day + , subq_4.visit__referrer_id + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_19.metric_time__day - , subq_19.visit__referrer_id - , SUM(subq_19.buys) AS buys + subq_15.metric_time__day + , subq_15.visit__referrer_id + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.visit__referrer_id - , subq_18.buys + subq_14.metric_time__day + , subq_14.visit__referrer_id + , subq_14.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_17.ds__day - , subq_17.metric_time__day - , subq_17.user - , subq_17.visit__referrer_id - , subq_17.buys - , subq_17.visits + subq_13.ds__day + , subq_13.metric_time__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_13.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_13.visit__referrer_id) OVER ( + , first_value(subq_9.visit__referrer_id) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_13.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_13.metric_time__day) OVER ( + , first_value(subq_9.metric_time__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , first_value(subq_13.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_16.mf_internal_uuid AS mf_internal_uuid - , subq_16.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] SELECT - subq_12.ds__day - , subq_12.metric_time__day - , subq_12.user - , subq_12.visit__referrer_id - , subq_12.visits + subq_8.ds__day + , subq_8.metric_time__day + , subq_8.user + , subq_8.visit__referrer_id + , subq_8.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.visit__ds__day - , subq_11.visit__ds__week - , subq_11.visit__ds__month - , subq_11.visit__ds__quarter - , subq_11.visit__ds__year - , subq_11.visit__ds__extract_year - , subq_11.visit__ds__extract_quarter - , subq_11.visit__ds__extract_month - , subq_11.visit__ds__extract_day - , subq_11.visit__ds__extract_dow - , subq_11.visit__ds__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session - , subq_11.visit__user - , subq_11.visit__session - , subq_11.referrer_id - , subq_11.visit__referrer_id - , subq_11.visits - , subq_11.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__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.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors 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.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__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.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + 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.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__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.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -357,96 +357,96 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_12 - ) subq_13 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.buy__ds__day - , subq_15.buy__ds__week - , subq_15.buy__ds__month - , subq_15.buy__ds__quarter - , subq_15.buy__ds__year - , subq_15.buy__ds__extract_year - , subq_15.buy__ds__extract_quarter - , subq_15.buy__ds__extract_month - , subq_15.buy__ds__extract_day - , subq_15.buy__ds__extract_dow - , subq_15.buy__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.user - , subq_15.session_id - , subq_15.buy__user - , subq_15.buy__session_id - , subq_15.buys - , subq_15.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , GEN_RANDOM_UUID() AS mf_internal_uuid 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.buy__ds__day - , subq_14.buy__ds__week - , subq_14.buy__ds__month - , subq_14.buy__ds__quarter - , subq_14.buy__ds__year - , subq_14.buy__ds__extract_year - , subq_14.buy__ds__extract_quarter - , subq_14.buy__ds__extract_month - , subq_14.buy__ds__extract_day - , subq_14.buy__ds__extract_dow - , subq_14.buy__ds__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.user - , subq_14.session_id - , subq_14.buy__user - , subq_14.buy__session_id - , subq_14.buys - , subq_14.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -479,33 +479,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_13.user = subq_16.user + subq_9.user = subq_12.user ) AND ( ( - subq_13.ds__day <= subq_16.ds__day + subq_9.ds__day <= subq_12.ds__day ) AND ( - subq_13.ds__day > subq_16.ds__day - MAKE_INTERVAL(days => 7) + subq_9.ds__day > subq_12.ds__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY - subq_19.metric_time__day - , subq_19.visit__referrer_id - ) subq_20 + subq_15.metric_time__day + , subq_15.visit__referrer_id + ) subq_16 ON ( - subq_9.visit__referrer_id = subq_20.visit__referrer_id + subq_5.visit__referrer_id = subq_16.visit__referrer_id ) AND ( - subq_9.metric_time__day = subq_20.metric_time__day + subq_5.metric_time__day = subq_16.metric_time__day ) GROUP BY - COALESCE(subq_9.metric_time__day, subq_20.metric_time__day) - , COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) -) subq_21 + COALESCE(subq_5.metric_time__day, subq_16.metric_time__day) + , COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) +) subq_17 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql index 75b9051b45..e0f957df74 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.metric_time__day, subq_42.metric_time__day) AS metric_time__day - , COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) AS visit__referrer_id - , MAX(subq_31.visits) AS visits - , MAX(subq_42.buys) AS buys + COALESCE(subq_23.metric_time__day, subq_34.metric_time__day) AS metric_time__day + , COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) AS visit__referrer_id + , MAX(subq_23.visits) AS visits + , MAX(subq_34.buys) AS buys FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -28,12 +28,12 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_29 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day , visit__referrer_id - ) subq_31 + ) subq_23 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -45,48 +45,48 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_35.visits) OVER ( + first_value(subq_27.visits) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_35.visit__referrer_id) OVER ( + , first_value(subq_27.visit__referrer_id) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_35.ds__day) OVER ( + , first_value(subq_27.ds__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_35.metric_time__day) OVER ( + , first_value(subq_27.metric_time__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , first_value(subq_35.user) OVER ( + , first_value(subq_27.user) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_38.mf_internal_uuid AS mf_internal_uuid - , subq_38.buys AS buys + , subq_30.mf_internal_uuid AS mf_internal_uuid + , subq_30.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -100,7 +100,7 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_35 + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -111,29 +111,29 @@ FROM ( , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_38 + ) subq_30 ON ( - subq_35.user = subq_38.user + subq_27.user = subq_30.user ) AND ( ( - subq_35.ds__day <= subq_38.ds__day + subq_27.ds__day <= subq_30.ds__day ) AND ( - subq_35.ds__day > subq_38.ds__day - MAKE_INTERVAL(days => 7) + subq_27.ds__day > subq_30.ds__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_39 + ) subq_31 GROUP BY metric_time__day , visit__referrer_id - ) subq_42 + ) subq_34 ON ( - subq_31.visit__referrer_id = subq_42.visit__referrer_id + subq_23.visit__referrer_id = subq_34.visit__referrer_id ) AND ( - subq_31.metric_time__day = subq_42.metric_time__day + subq_23.metric_time__day = subq_34.metric_time__day ) GROUP BY - COALESCE(subq_31.metric_time__day, subq_42.metric_time__day) - , COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) -) subq_43 + COALESCE(subq_23.metric_time__day, subq_34.metric_time__day) + , COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) +) subq_35 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_time_constraint__plan0.sql index 756a827b2b..78bfdd302a 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_time_constraint__plan0.sql @@ -1,116 +1,116 @@ -- Compute Metrics via Expressions SELECT - subq_21.visit__referrer_id - , CAST(subq_21.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_21.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate + subq_17.visit__referrer_id + , CAST(subq_17.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) AS visit__referrer_id - , MAX(subq_9.visits) AS visits - , MAX(subq_20.buys) AS buys + COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) AS visit__referrer_id + , MAX(subq_5.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.visit__referrer_id - , SUM(subq_8.visits) AS visits + subq_4.visit__referrer_id + , SUM(subq_4.visits) AS visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.visit__referrer_id - , subq_7.visits + subq_3.visit__referrer_id + , subq_3.visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT - subq_6.visit__referrer_id - , subq_6.visits + subq_2.visit__referrer_id + , subq_2.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.visit__ds__day - , subq_5.visit__ds__week - , subq_5.visit__ds__month - , subq_5.visit__ds__quarter - , subq_5.visit__ds__year - , subq_5.visit__ds__extract_year - , subq_5.visit__ds__extract_quarter - , subq_5.visit__ds__extract_month - , subq_5.visit__ds__extract_day - , subq_5.visit__ds__extract_dow - , subq_5.visit__ds__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.user - , subq_5.session - , subq_5.visit__user - , subq_5.visit__session - , subq_5.referrer_id - , subq_5.visit__referrer_id - , subq_5.visits - , subq_5.visitors + 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.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -145,166 +145,166 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_2 + ) subq_3 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 + ) subq_4 GROUP BY - subq_8.visit__referrer_id - ) subq_9 + subq_4.visit__referrer_id + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_19.visit__referrer_id - , SUM(subq_19.buys) AS buys + subq_15.visit__referrer_id + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id'] SELECT - subq_18.visit__referrer_id - , subq_18.buys + subq_14.visit__referrer_id + , subq_14.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_17.ds__day - , subq_17.user - , subq_17.visit__referrer_id - , subq_17.buys - , subq_17.visits + subq_13.ds__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_13.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_13.visit__referrer_id) OVER ( + , first_value(subq_9.visit__referrer_id) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_13.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_13.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_16.mf_internal_uuid AS mf_internal_uuid - , subq_16.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user'] SELECT - subq_12.ds__day - , subq_12.user - , subq_12.visit__referrer_id - , subq_12.visits + subq_8.ds__day + , subq_8.user + , subq_8.visit__referrer_id + , subq_8.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.visit__ds__day - , subq_11.visit__ds__week - , subq_11.visit__ds__month - , subq_11.visit__ds__quarter - , subq_11.visit__ds__year - , subq_11.visit__ds__extract_year - , subq_11.visit__ds__extract_quarter - , subq_11.visit__ds__extract_month - , subq_11.visit__ds__extract_day - , subq_11.visit__ds__extract_dow - , subq_11.visit__ds__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session - , subq_11.visit__user - , subq_11.visit__session - , subq_11.referrer_id - , subq_11.visit__referrer_id - , subq_11.visits - , subq_11.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__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.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors 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.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__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.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + 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.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__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.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -339,96 +339,96 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_12 - ) subq_13 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.buy__ds__day - , subq_15.buy__ds__week - , subq_15.buy__ds__month - , subq_15.buy__ds__quarter - , subq_15.buy__ds__year - , subq_15.buy__ds__extract_year - , subq_15.buy__ds__extract_quarter - , subq_15.buy__ds__extract_month - , subq_15.buy__ds__extract_day - , subq_15.buy__ds__extract_dow - , subq_15.buy__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.user - , subq_15.session_id - , subq_15.buy__user - , subq_15.buy__session_id - , subq_15.buys - , subq_15.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_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.buy__ds__day - , subq_14.buy__ds__week - , subq_14.buy__ds__month - , subq_14.buy__ds__quarter - , subq_14.buy__ds__year - , subq_14.buy__ds__extract_year - , subq_14.buy__ds__extract_quarter - , subq_14.buy__ds__extract_month - , subq_14.buy__ds__extract_day - , subq_14.buy__ds__extract_dow - , subq_14.buy__ds__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.user - , subq_14.session_id - , subq_14.buy__user - , subq_14.buy__session_id - , subq_14.buys - , subq_14.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -461,23 +461,23 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_13.user = subq_16.user + subq_9.user = subq_12.user ) AND ( - (subq_13.ds__day <= subq_16.ds__day) + (subq_9.ds__day <= subq_12.ds__day) ) - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY - subq_19.visit__referrer_id - ) subq_20 + subq_15.visit__referrer_id + ) subq_16 ON - subq_9.visit__referrer_id = subq_20.visit__referrer_id + subq_5.visit__referrer_id = subq_16.visit__referrer_id GROUP BY - COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) -) subq_21 + COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) +) subq_17 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_time_constraint__plan0_optimized.sql index 9ba278ba75..569264cbda 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_time_constraint__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) AS visit__referrer_id - , MAX(subq_31.visits) AS visits - , MAX(subq_42.buys) AS buys + COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) AS visit__referrer_id + , MAX(subq_23.visits) AS visits + , MAX(subq_34.buys) AS buys FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -24,11 +24,11 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_29 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY visit__referrer_id - ) subq_31 + ) subq_23 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'visit__referrer_id'] @@ -39,40 +39,40 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_35.visits) OVER ( + first_value(subq_27.visits) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_35.visit__referrer_id) OVER ( + , first_value(subq_27.visit__referrer_id) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_35.ds__day) OVER ( + , first_value(subq_27.ds__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_35.user) OVER ( + , first_value(subq_27.user) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_38.mf_internal_uuid AS mf_internal_uuid - , subq_38.buys AS buys + , subq_30.mf_internal_uuid AS mf_internal_uuid + , subq_30.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -85,7 +85,7 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_35 + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -96,19 +96,19 @@ FROM ( , 1 AS buys , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_38 + ) subq_30 ON ( - subq_35.user = subq_38.user + subq_27.user = subq_30.user ) AND ( - (subq_35.ds__day <= subq_38.ds__day) + (subq_27.ds__day <= subq_30.ds__day) ) - ) subq_39 + ) subq_31 GROUP BY visit__referrer_id - ) subq_42 + ) subq_34 ON - subq_31.visit__referrer_id = subq_42.visit__referrer_id + subq_23.visit__referrer_id = subq_34.visit__referrer_id GROUP BY - COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) -) subq_43 + COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) +) subq_35 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window_and_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window_and_time_constraint__plan0.sql index a52fd49abb..f0367b89f7 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window_and_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window_and_time_constraint__plan0.sql @@ -1,121 +1,121 @@ -- Compute Metrics via Expressions SELECT - subq_21.metric_time__day - , subq_21.visit__referrer_id - , CAST(subq_21.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_21.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + subq_17.metric_time__day + , subq_17.visit__referrer_id + , CAST(subq_17.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) AS visit__referrer_id - , MAX(subq_9.visits) AS visits - , MAX(subq_20.buys) AS buys + COALESCE(subq_5.metric_time__day, subq_16.metric_time__day) AS metric_time__day + , COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) AS visit__referrer_id + , MAX(subq_5.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , subq_8.visit__referrer_id - , SUM(subq_8.visits) AS visits + subq_4.metric_time__day + , subq_4.visit__referrer_id + , SUM(subq_4.visits) AS visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.visit__referrer_id - , subq_7.visits + subq_3.metric_time__day + , subq_3.visit__referrer_id + , subq_3.visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.visit__referrer_id - , subq_6.visits + subq_2.metric_time__day + , subq_2.visit__referrer_id + , subq_2.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.visit__ds__day - , subq_5.visit__ds__week - , subq_5.visit__ds__month - , subq_5.visit__ds__quarter - , subq_5.visit__ds__year - , subq_5.visit__ds__extract_year - , subq_5.visit__ds__extract_quarter - , subq_5.visit__ds__extract_month - , subq_5.visit__ds__extract_day - , subq_5.visit__ds__extract_dow - , subq_5.visit__ds__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.user - , subq_5.session - , subq_5.visit__user - , subq_5.visit__session - , subq_5.referrer_id - , subq_5.visit__referrer_id - , subq_5.visits - , subq_5.visitors + 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.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -150,179 +150,179 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_2 + ) subq_3 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 + ) subq_4 GROUP BY - subq_8.metric_time__day - , subq_8.visit__referrer_id - ) subq_9 + subq_4.metric_time__day + , subq_4.visit__referrer_id + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_19.metric_time__day - , subq_19.visit__referrer_id - , SUM(subq_19.buys) AS buys + subq_15.metric_time__day + , subq_15.visit__referrer_id + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.visit__referrer_id - , subq_18.buys + subq_14.metric_time__day + , subq_14.visit__referrer_id + , subq_14.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_17.ds__day - , subq_17.metric_time__day - , subq_17.user - , subq_17.visit__referrer_id - , subq_17.buys - , subq_17.visits + subq_13.ds__day + , subq_13.metric_time__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_13.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_13.visit__referrer_id) OVER ( + , first_value(subq_9.visit__referrer_id) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_13.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_13.metric_time__day) OVER ( + , first_value(subq_9.metric_time__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , first_value(subq_13.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_16.mf_internal_uuid AS mf_internal_uuid - , subq_16.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] SELECT - subq_12.ds__day - , subq_12.metric_time__day - , subq_12.user - , subq_12.visit__referrer_id - , subq_12.visits + subq_8.ds__day + , subq_8.metric_time__day + , subq_8.user + , subq_8.visit__referrer_id + , subq_8.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.visit__ds__day - , subq_11.visit__ds__week - , subq_11.visit__ds__month - , subq_11.visit__ds__quarter - , subq_11.visit__ds__year - , subq_11.visit__ds__extract_year - , subq_11.visit__ds__extract_quarter - , subq_11.visit__ds__extract_month - , subq_11.visit__ds__extract_day - , subq_11.visit__ds__extract_dow - , subq_11.visit__ds__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session - , subq_11.visit__user - , subq_11.visit__session - , subq_11.referrer_id - , subq_11.visit__referrer_id - , subq_11.visits - , subq_11.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__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.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors 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.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__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.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + 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.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__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.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -357,96 +357,96 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_12 - ) subq_13 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.buy__ds__day - , subq_15.buy__ds__week - , subq_15.buy__ds__month - , subq_15.buy__ds__quarter - , subq_15.buy__ds__year - , subq_15.buy__ds__extract_year - , subq_15.buy__ds__extract_quarter - , subq_15.buy__ds__extract_month - , subq_15.buy__ds__extract_day - , subq_15.buy__ds__extract_dow - , subq_15.buy__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.user - , subq_15.session_id - , subq_15.buy__user - , subq_15.buy__session_id - , subq_15.buys - , subq_15.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_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.buy__ds__day - , subq_14.buy__ds__week - , subq_14.buy__ds__month - , subq_14.buy__ds__quarter - , subq_14.buy__ds__year - , subq_14.buy__ds__extract_year - , subq_14.buy__ds__extract_quarter - , subq_14.buy__ds__extract_month - , subq_14.buy__ds__extract_day - , subq_14.buy__ds__extract_dow - , subq_14.buy__ds__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.user - , subq_14.session_id - , subq_14.buy__user - , subq_14.buy__session_id - , subq_14.buys - , subq_14.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -479,33 +479,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_13.user = subq_16.user + subq_9.user = subq_12.user ) AND ( ( - subq_13.ds__day <= subq_16.ds__day + subq_9.ds__day <= subq_12.ds__day ) AND ( - subq_13.ds__day > DATEADD(day, -7, subq_16.ds__day) + subq_9.ds__day > DATEADD(day, -7, subq_12.ds__day) ) ) - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY - subq_19.metric_time__day - , subq_19.visit__referrer_id - ) subq_20 + subq_15.metric_time__day + , subq_15.visit__referrer_id + ) subq_16 ON ( - subq_9.visit__referrer_id = subq_20.visit__referrer_id + subq_5.visit__referrer_id = subq_16.visit__referrer_id ) AND ( - subq_9.metric_time__day = subq_20.metric_time__day + subq_5.metric_time__day = subq_16.metric_time__day ) GROUP BY - COALESCE(subq_9.metric_time__day, subq_20.metric_time__day) - , COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) -) subq_21 + COALESCE(subq_5.metric_time__day, subq_16.metric_time__day) + , COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) +) subq_17 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql index 8f836d5048..c21e5c32ac 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.metric_time__day, subq_42.metric_time__day) AS metric_time__day - , COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) AS visit__referrer_id - , MAX(subq_31.visits) AS visits - , MAX(subq_42.buys) AS buys + COALESCE(subq_23.metric_time__day, subq_34.metric_time__day) AS metric_time__day + , COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) AS visit__referrer_id + , MAX(subq_23.visits) AS visits + , MAX(subq_34.buys) AS buys FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -28,12 +28,12 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_29 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day , visit__referrer_id - ) subq_31 + ) subq_23 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -45,48 +45,48 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_35.visits) OVER ( + first_value(subq_27.visits) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_35.visit__referrer_id) OVER ( + , first_value(subq_27.visit__referrer_id) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_35.ds__day) OVER ( + , first_value(subq_27.ds__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_35.metric_time__day) OVER ( + , first_value(subq_27.metric_time__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , first_value(subq_35.user) OVER ( + , first_value(subq_27.user) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_38.mf_internal_uuid AS mf_internal_uuid - , subq_38.buys AS buys + , subq_30.mf_internal_uuid AS mf_internal_uuid + , subq_30.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -100,7 +100,7 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_35 + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -111,29 +111,29 @@ FROM ( , 1 AS buys , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_38 + ) subq_30 ON ( - subq_35.user = subq_38.user + subq_27.user = subq_30.user ) AND ( ( - subq_35.ds__day <= subq_38.ds__day + subq_27.ds__day <= subq_30.ds__day ) AND ( - subq_35.ds__day > DATEADD(day, -7, subq_38.ds__day) + subq_27.ds__day > DATEADD(day, -7, subq_30.ds__day) ) ) - ) subq_39 + ) subq_31 GROUP BY metric_time__day , visit__referrer_id - ) subq_42 + ) subq_34 ON ( - subq_31.visit__referrer_id = subq_42.visit__referrer_id + subq_23.visit__referrer_id = subq_34.visit__referrer_id ) AND ( - subq_31.metric_time__day = subq_42.metric_time__day + subq_23.metric_time__day = subq_34.metric_time__day ) GROUP BY - COALESCE(subq_31.metric_time__day, subq_42.metric_time__day) - , COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) -) subq_43 + COALESCE(subq_23.metric_time__day, subq_34.metric_time__day) + , COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) +) subq_35 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_time_constraint__plan0.sql index fef0bde96e..b27b0eea56 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_time_constraint__plan0.sql @@ -1,116 +1,116 @@ -- Compute Metrics via Expressions SELECT - subq_21.visit__referrer_id - , CAST(subq_21.buys AS DOUBLE) / CAST(NULLIF(subq_21.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate + subq_17.visit__referrer_id + , CAST(subq_17.buys AS DOUBLE) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) AS visit__referrer_id - , MAX(subq_9.visits) AS visits - , MAX(subq_20.buys) AS buys + COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) AS visit__referrer_id + , MAX(subq_5.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.visit__referrer_id - , SUM(subq_8.visits) AS visits + subq_4.visit__referrer_id + , SUM(subq_4.visits) AS visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.visit__referrer_id - , subq_7.visits + subq_3.visit__referrer_id + , subq_3.visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT - subq_6.visit__referrer_id - , subq_6.visits + subq_2.visit__referrer_id + , subq_2.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.visit__ds__day - , subq_5.visit__ds__week - , subq_5.visit__ds__month - , subq_5.visit__ds__quarter - , subq_5.visit__ds__year - , subq_5.visit__ds__extract_year - , subq_5.visit__ds__extract_quarter - , subq_5.visit__ds__extract_month - , subq_5.visit__ds__extract_day - , subq_5.visit__ds__extract_dow - , subq_5.visit__ds__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.user - , subq_5.session - , subq_5.visit__user - , subq_5.visit__session - , subq_5.referrer_id - , subq_5.visit__referrer_id - , subq_5.visits - , subq_5.visitors + 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.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -145,166 +145,166 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_2 + ) subq_3 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 + ) subq_4 GROUP BY - subq_8.visit__referrer_id - ) subq_9 + subq_4.visit__referrer_id + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_19.visit__referrer_id - , SUM(subq_19.buys) AS buys + subq_15.visit__referrer_id + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id'] SELECT - subq_18.visit__referrer_id - , subq_18.buys + subq_14.visit__referrer_id + , subq_14.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_17.ds__day - , subq_17.user - , subq_17.visit__referrer_id - , subq_17.buys - , subq_17.visits + subq_13.ds__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_13.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_13.visit__referrer_id) OVER ( + , first_value(subq_9.visit__referrer_id) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_13.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_13.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_16.mf_internal_uuid AS mf_internal_uuid - , subq_16.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user'] SELECT - subq_12.ds__day - , subq_12.user - , subq_12.visit__referrer_id - , subq_12.visits + subq_8.ds__day + , subq_8.user + , subq_8.visit__referrer_id + , subq_8.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.visit__ds__day - , subq_11.visit__ds__week - , subq_11.visit__ds__month - , subq_11.visit__ds__quarter - , subq_11.visit__ds__year - , subq_11.visit__ds__extract_year - , subq_11.visit__ds__extract_quarter - , subq_11.visit__ds__extract_month - , subq_11.visit__ds__extract_day - , subq_11.visit__ds__extract_dow - , subq_11.visit__ds__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session - , subq_11.visit__user - , subq_11.visit__session - , subq_11.referrer_id - , subq_11.visit__referrer_id - , subq_11.visits - , subq_11.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__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.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors 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.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__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.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + 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.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__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.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -339,96 +339,96 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_12 - ) subq_13 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.buy__ds__day - , subq_15.buy__ds__week - , subq_15.buy__ds__month - , subq_15.buy__ds__quarter - , subq_15.buy__ds__year - , subq_15.buy__ds__extract_year - , subq_15.buy__ds__extract_quarter - , subq_15.buy__ds__extract_month - , subq_15.buy__ds__extract_day - , subq_15.buy__ds__extract_dow - , subq_15.buy__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.user - , subq_15.session_id - , subq_15.buy__user - , subq_15.buy__session_id - , subq_15.buys - , subq_15.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , UUID_STRING() AS mf_internal_uuid 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.buy__ds__day - , subq_14.buy__ds__week - , subq_14.buy__ds__month - , subq_14.buy__ds__quarter - , subq_14.buy__ds__year - , subq_14.buy__ds__extract_year - , subq_14.buy__ds__extract_quarter - , subq_14.buy__ds__extract_month - , subq_14.buy__ds__extract_day - , subq_14.buy__ds__extract_dow - , subq_14.buy__ds__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.user - , subq_14.session_id - , subq_14.buy__user - , subq_14.buy__session_id - , subq_14.buys - , subq_14.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -461,23 +461,23 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_13.user = subq_16.user + subq_9.user = subq_12.user ) AND ( - (subq_13.ds__day <= subq_16.ds__day) + (subq_9.ds__day <= subq_12.ds__day) ) - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY - subq_19.visit__referrer_id - ) subq_20 + subq_15.visit__referrer_id + ) subq_16 ON - subq_9.visit__referrer_id = subq_20.visit__referrer_id + subq_5.visit__referrer_id = subq_16.visit__referrer_id GROUP BY - COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) -) subq_21 + COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) +) subq_17 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_time_constraint__plan0_optimized.sql index 3ae4060ca1..7cff5c4a26 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_time_constraint__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) AS visit__referrer_id - , MAX(subq_31.visits) AS visits - , MAX(subq_42.buys) AS buys + COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) AS visit__referrer_id + , MAX(subq_23.visits) AS visits + , MAX(subq_34.buys) AS buys FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -24,11 +24,11 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_29 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY visit__referrer_id - ) subq_31 + ) subq_23 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'visit__referrer_id'] @@ -39,40 +39,40 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_35.visits) OVER ( + first_value(subq_27.visits) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_35.visit__referrer_id) OVER ( + , first_value(subq_27.visit__referrer_id) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_35.ds__day) OVER ( + , first_value(subq_27.ds__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_35.user) OVER ( + , first_value(subq_27.user) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_38.mf_internal_uuid AS mf_internal_uuid - , subq_38.buys AS buys + , subq_30.mf_internal_uuid AS mf_internal_uuid + , subq_30.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -85,7 +85,7 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_35 + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -96,19 +96,19 @@ FROM ( , 1 AS buys , UUID_STRING() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_38 + ) subq_30 ON ( - subq_35.user = subq_38.user + subq_27.user = subq_30.user ) AND ( - (subq_35.ds__day <= subq_38.ds__day) + (subq_27.ds__day <= subq_30.ds__day) ) - ) subq_39 + ) subq_31 GROUP BY visit__referrer_id - ) subq_42 + ) subq_34 ON - subq_31.visit__referrer_id = subq_42.visit__referrer_id + subq_23.visit__referrer_id = subq_34.visit__referrer_id GROUP BY - COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) -) subq_43 + COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) +) subq_35 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window_and_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window_and_time_constraint__plan0.sql index b06093216b..44ce1d9a09 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window_and_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window_and_time_constraint__plan0.sql @@ -1,121 +1,121 @@ -- Compute Metrics via Expressions SELECT - subq_21.metric_time__day - , subq_21.visit__referrer_id - , CAST(subq_21.buys AS DOUBLE) / CAST(NULLIF(subq_21.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + subq_17.metric_time__day + , subq_17.visit__referrer_id + , CAST(subq_17.buys AS DOUBLE) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) AS visit__referrer_id - , MAX(subq_9.visits) AS visits - , MAX(subq_20.buys) AS buys + COALESCE(subq_5.metric_time__day, subq_16.metric_time__day) AS metric_time__day + , COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) AS visit__referrer_id + , MAX(subq_5.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , subq_8.visit__referrer_id - , SUM(subq_8.visits) AS visits + subq_4.metric_time__day + , subq_4.visit__referrer_id + , SUM(subq_4.visits) AS visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.visit__referrer_id - , subq_7.visits + subq_3.metric_time__day + , subq_3.visit__referrer_id + , subq_3.visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.visit__referrer_id - , subq_6.visits + subq_2.metric_time__day + , subq_2.visit__referrer_id + , subq_2.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.visit__ds__day - , subq_5.visit__ds__week - , subq_5.visit__ds__month - , subq_5.visit__ds__quarter - , subq_5.visit__ds__year - , subq_5.visit__ds__extract_year - , subq_5.visit__ds__extract_quarter - , subq_5.visit__ds__extract_month - , subq_5.visit__ds__extract_day - , subq_5.visit__ds__extract_dow - , subq_5.visit__ds__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.user - , subq_5.session - , subq_5.visit__user - , subq_5.visit__session - , subq_5.referrer_id - , subq_5.visit__referrer_id - , subq_5.visits - , subq_5.visitors + 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.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -150,179 +150,179 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_2 + ) subq_3 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 + ) subq_4 GROUP BY - subq_8.metric_time__day - , subq_8.visit__referrer_id - ) subq_9 + subq_4.metric_time__day + , subq_4.visit__referrer_id + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_19.metric_time__day - , subq_19.visit__referrer_id - , SUM(subq_19.buys) AS buys + subq_15.metric_time__day + , subq_15.visit__referrer_id + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.visit__referrer_id - , subq_18.buys + subq_14.metric_time__day + , subq_14.visit__referrer_id + , subq_14.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_17.ds__day - , subq_17.metric_time__day - , subq_17.user - , subq_17.visit__referrer_id - , subq_17.buys - , subq_17.visits + subq_13.ds__day + , subq_13.metric_time__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_13.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_13.visit__referrer_id) OVER ( + , first_value(subq_9.visit__referrer_id) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_13.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_13.metric_time__day) OVER ( + , first_value(subq_9.metric_time__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , first_value(subq_13.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_16.mf_internal_uuid AS mf_internal_uuid - , subq_16.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] SELECT - subq_12.ds__day - , subq_12.metric_time__day - , subq_12.user - , subq_12.visit__referrer_id - , subq_12.visits + subq_8.ds__day + , subq_8.metric_time__day + , subq_8.user + , subq_8.visit__referrer_id + , subq_8.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.visit__ds__day - , subq_11.visit__ds__week - , subq_11.visit__ds__month - , subq_11.visit__ds__quarter - , subq_11.visit__ds__year - , subq_11.visit__ds__extract_year - , subq_11.visit__ds__extract_quarter - , subq_11.visit__ds__extract_month - , subq_11.visit__ds__extract_day - , subq_11.visit__ds__extract_dow - , subq_11.visit__ds__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session - , subq_11.visit__user - , subq_11.visit__session - , subq_11.referrer_id - , subq_11.visit__referrer_id - , subq_11.visits - , subq_11.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__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.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors 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.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__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.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + 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.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__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.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -357,96 +357,96 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_12 - ) subq_13 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.buy__ds__day - , subq_15.buy__ds__week - , subq_15.buy__ds__month - , subq_15.buy__ds__quarter - , subq_15.buy__ds__year - , subq_15.buy__ds__extract_year - , subq_15.buy__ds__extract_quarter - , subq_15.buy__ds__extract_month - , subq_15.buy__ds__extract_day - , subq_15.buy__ds__extract_dow - , subq_15.buy__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.user - , subq_15.session_id - , subq_15.buy__user - , subq_15.buy__session_id - , subq_15.buys - , subq_15.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , UUID_STRING() AS mf_internal_uuid 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.buy__ds__day - , subq_14.buy__ds__week - , subq_14.buy__ds__month - , subq_14.buy__ds__quarter - , subq_14.buy__ds__year - , subq_14.buy__ds__extract_year - , subq_14.buy__ds__extract_quarter - , subq_14.buy__ds__extract_month - , subq_14.buy__ds__extract_day - , subq_14.buy__ds__extract_dow - , subq_14.buy__ds__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.user - , subq_14.session_id - , subq_14.buy__user - , subq_14.buy__session_id - , subq_14.buys - , subq_14.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -479,33 +479,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_13.user = subq_16.user + subq_9.user = subq_12.user ) AND ( ( - subq_13.ds__day <= subq_16.ds__day + subq_9.ds__day <= subq_12.ds__day ) AND ( - subq_13.ds__day > DATEADD(day, -7, subq_16.ds__day) + subq_9.ds__day > DATEADD(day, -7, subq_12.ds__day) ) ) - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY - subq_19.metric_time__day - , subq_19.visit__referrer_id - ) subq_20 + subq_15.metric_time__day + , subq_15.visit__referrer_id + ) subq_16 ON ( - subq_9.visit__referrer_id = subq_20.visit__referrer_id + subq_5.visit__referrer_id = subq_16.visit__referrer_id ) AND ( - subq_9.metric_time__day = subq_20.metric_time__day + subq_5.metric_time__day = subq_16.metric_time__day ) GROUP BY - COALESCE(subq_9.metric_time__day, subq_20.metric_time__day) - , COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) -) subq_21 + COALESCE(subq_5.metric_time__day, subq_16.metric_time__day) + , COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) +) subq_17 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql index 885789a495..81e4890b4d 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.metric_time__day, subq_42.metric_time__day) AS metric_time__day - , COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) AS visit__referrer_id - , MAX(subq_31.visits) AS visits - , MAX(subq_42.buys) AS buys + COALESCE(subq_23.metric_time__day, subq_34.metric_time__day) AS metric_time__day + , COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) AS visit__referrer_id + , MAX(subq_23.visits) AS visits + , MAX(subq_34.buys) AS buys FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -28,12 +28,12 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_29 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day , visit__referrer_id - ) subq_31 + ) subq_23 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -45,48 +45,48 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_35.visits) OVER ( + first_value(subq_27.visits) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_35.visit__referrer_id) OVER ( + , first_value(subq_27.visit__referrer_id) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_35.ds__day) OVER ( + , first_value(subq_27.ds__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_35.metric_time__day) OVER ( + , first_value(subq_27.metric_time__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , first_value(subq_35.user) OVER ( + , first_value(subq_27.user) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_38.mf_internal_uuid AS mf_internal_uuid - , subq_38.buys AS buys + , subq_30.mf_internal_uuid AS mf_internal_uuid + , subq_30.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -100,7 +100,7 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_35 + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -111,29 +111,29 @@ FROM ( , 1 AS buys , UUID_STRING() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_38 + ) subq_30 ON ( - subq_35.user = subq_38.user + subq_27.user = subq_30.user ) AND ( ( - subq_35.ds__day <= subq_38.ds__day + subq_27.ds__day <= subq_30.ds__day ) AND ( - subq_35.ds__day > DATEADD(day, -7, subq_38.ds__day) + subq_27.ds__day > DATEADD(day, -7, subq_30.ds__day) ) ) - ) subq_39 + ) subq_31 GROUP BY metric_time__day , visit__referrer_id - ) subq_42 + ) subq_34 ON ( - subq_31.visit__referrer_id = subq_42.visit__referrer_id + subq_23.visit__referrer_id = subq_34.visit__referrer_id ) AND ( - subq_31.metric_time__day = subq_42.metric_time__day + subq_23.metric_time__day = subq_34.metric_time__day ) GROUP BY - COALESCE(subq_31.metric_time__day, subq_42.metric_time__day) - , COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) -) subq_43 + COALESCE(subq_23.metric_time__day, subq_34.metric_time__day) + , COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) +) subq_35 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_time_constraint__plan0.sql index 928fef3d5f..bc2fe60f70 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_time_constraint__plan0.sql @@ -1,116 +1,116 @@ -- Compute Metrics via Expressions SELECT - subq_21.visit__referrer_id - , CAST(subq_21.buys AS DOUBLE) / CAST(NULLIF(subq_21.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate + subq_17.visit__referrer_id + , CAST(subq_17.buys AS DOUBLE) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) AS visit__referrer_id - , MAX(subq_9.visits) AS visits - , MAX(subq_20.buys) AS buys + COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) AS visit__referrer_id + , MAX(subq_5.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.visit__referrer_id - , SUM(subq_8.visits) AS visits + subq_4.visit__referrer_id + , SUM(subq_4.visits) AS visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.visit__referrer_id - , subq_7.visits + subq_3.visit__referrer_id + , subq_3.visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT - subq_6.visit__referrer_id - , subq_6.visits + subq_2.visit__referrer_id + , subq_2.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.visit__ds__day - , subq_5.visit__ds__week - , subq_5.visit__ds__month - , subq_5.visit__ds__quarter - , subq_5.visit__ds__year - , subq_5.visit__ds__extract_year - , subq_5.visit__ds__extract_quarter - , subq_5.visit__ds__extract_month - , subq_5.visit__ds__extract_day - , subq_5.visit__ds__extract_dow - , subq_5.visit__ds__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.user - , subq_5.session - , subq_5.visit__user - , subq_5.visit__session - , subq_5.referrer_id - , subq_5.visit__referrer_id - , subq_5.visits - , subq_5.visitors + 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.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -145,166 +145,166 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' + ) subq_2 + ) subq_3 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 + ) subq_4 GROUP BY - subq_8.visit__referrer_id - ) subq_9 + subq_4.visit__referrer_id + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_19.visit__referrer_id - , SUM(subq_19.buys) AS buys + subq_15.visit__referrer_id + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id'] SELECT - subq_18.visit__referrer_id - , subq_18.buys + subq_14.visit__referrer_id + , subq_14.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_17.ds__day - , subq_17.user - , subq_17.visit__referrer_id - , subq_17.buys - , subq_17.visits + subq_13.ds__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_13.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_13.visit__referrer_id) OVER ( + , first_value(subq_9.visit__referrer_id) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_13.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_13.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_16.mf_internal_uuid AS mf_internal_uuid - , subq_16.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user'] SELECT - subq_12.ds__day - , subq_12.user - , subq_12.visit__referrer_id - , subq_12.visits + subq_8.ds__day + , subq_8.user + , subq_8.visit__referrer_id + , subq_8.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.visit__ds__day - , subq_11.visit__ds__week - , subq_11.visit__ds__month - , subq_11.visit__ds__quarter - , subq_11.visit__ds__year - , subq_11.visit__ds__extract_year - , subq_11.visit__ds__extract_quarter - , subq_11.visit__ds__extract_month - , subq_11.visit__ds__extract_day - , subq_11.visit__ds__extract_dow - , subq_11.visit__ds__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session - , subq_11.visit__user - , subq_11.visit__session - , subq_11.referrer_id - , subq_11.visit__referrer_id - , subq_11.visits - , subq_11.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__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.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors 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.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__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.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + 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.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__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.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -339,96 +339,96 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' - ) subq_12 - ) subq_13 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.buy__ds__day - , subq_15.buy__ds__week - , subq_15.buy__ds__month - , subq_15.buy__ds__quarter - , subq_15.buy__ds__year - , subq_15.buy__ds__extract_year - , subq_15.buy__ds__extract_quarter - , subq_15.buy__ds__extract_month - , subq_15.buy__ds__extract_day - , subq_15.buy__ds__extract_dow - , subq_15.buy__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.user - , subq_15.session_id - , subq_15.buy__user - , subq_15.buy__session_id - , subq_15.buys - , subq_15.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , uuid() AS mf_internal_uuid 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.buy__ds__day - , subq_14.buy__ds__week - , subq_14.buy__ds__month - , subq_14.buy__ds__quarter - , subq_14.buy__ds__year - , subq_14.buy__ds__extract_year - , subq_14.buy__ds__extract_quarter - , subq_14.buy__ds__extract_month - , subq_14.buy__ds__extract_day - , subq_14.buy__ds__extract_dow - , subq_14.buy__ds__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.user - , subq_14.session_id - , subq_14.buy__user - , subq_14.buy__session_id - , subq_14.buys - , subq_14.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -461,23 +461,23 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_13.user = subq_16.user + subq_9.user = subq_12.user ) AND ( - (subq_13.ds__day <= subq_16.ds__day) + (subq_9.ds__day <= subq_12.ds__day) ) - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY - subq_19.visit__referrer_id - ) subq_20 + subq_15.visit__referrer_id + ) subq_16 ON - subq_9.visit__referrer_id = subq_20.visit__referrer_id + subq_5.visit__referrer_id = subq_16.visit__referrer_id GROUP BY - COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) -) subq_21 + COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) +) subq_17 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_time_constraint__plan0_optimized.sql index 84682a559a..62871c0016 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_time_constraint__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) AS visit__referrer_id - , MAX(subq_31.visits) AS visits - , MAX(subq_42.buys) AS buys + COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) AS visit__referrer_id + , MAX(subq_23.visits) AS visits + , MAX(subq_34.buys) AS buys FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -24,11 +24,11 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' - ) subq_29 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY visit__referrer_id - ) subq_31 + ) subq_23 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'visit__referrer_id'] @@ -39,40 +39,40 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_35.visits) OVER ( + first_value(subq_27.visits) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_35.visit__referrer_id) OVER ( + , first_value(subq_27.visit__referrer_id) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_35.ds__day) OVER ( + , first_value(subq_27.ds__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_35.user) OVER ( + , first_value(subq_27.user) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_38.mf_internal_uuid AS mf_internal_uuid - , subq_38.buys AS buys + , subq_30.mf_internal_uuid AS mf_internal_uuid + , subq_30.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -85,7 +85,7 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' - ) subq_35 + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -96,19 +96,19 @@ FROM ( , 1 AS buys , uuid() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_38 + ) subq_30 ON ( - subq_35.user = subq_38.user + subq_27.user = subq_30.user ) AND ( - (subq_35.ds__day <= subq_38.ds__day) + (subq_27.ds__day <= subq_30.ds__day) ) - ) subq_39 + ) subq_31 GROUP BY visit__referrer_id - ) subq_42 + ) subq_34 ON - subq_31.visit__referrer_id = subq_42.visit__referrer_id + subq_23.visit__referrer_id = subq_34.visit__referrer_id GROUP BY - COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) -) subq_43 + COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) +) subq_35 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window_and_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window_and_time_constraint__plan0.sql index 8f4d837d95..7ad71f8897 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window_and_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window_and_time_constraint__plan0.sql @@ -1,121 +1,121 @@ -- Compute Metrics via Expressions SELECT - subq_21.metric_time__day - , subq_21.visit__referrer_id - , CAST(subq_21.buys AS DOUBLE) / CAST(NULLIF(subq_21.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + subq_17.metric_time__day + , subq_17.visit__referrer_id + , CAST(subq_17.buys AS DOUBLE) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) AS visit__referrer_id - , MAX(subq_9.visits) AS visits - , MAX(subq_20.buys) AS buys + COALESCE(subq_5.metric_time__day, subq_16.metric_time__day) AS metric_time__day + , COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) AS visit__referrer_id + , MAX(subq_5.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , subq_8.visit__referrer_id - , SUM(subq_8.visits) AS visits + subq_4.metric_time__day + , subq_4.visit__referrer_id + , SUM(subq_4.visits) AS visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.visit__referrer_id - , subq_7.visits + subq_3.metric_time__day + , subq_3.visit__referrer_id + , subq_3.visits FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.visit__referrer_id - , subq_6.visits + subq_2.metric_time__day + , subq_2.visit__referrer_id + , subq_2.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.visit__ds__day - , subq_5.visit__ds__week - , subq_5.visit__ds__month - , subq_5.visit__ds__quarter - , subq_5.visit__ds__year - , subq_5.visit__ds__extract_year - , subq_5.visit__ds__extract_quarter - , subq_5.visit__ds__extract_month - , subq_5.visit__ds__extract_day - , subq_5.visit__ds__extract_dow - , subq_5.visit__ds__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.user - , subq_5.session - , subq_5.visit__user - , subq_5.visit__session - , subq_5.referrer_id - , subq_5.visit__referrer_id - , subq_5.visits - , subq_5.visitors + 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.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.visit__ds__day - , subq_4.visit__ds__week - , subq_4.visit__ds__month - , subq_4.visit__ds__quarter - , subq_4.visit__ds__year - , subq_4.visit__ds__extract_year - , subq_4.visit__ds__extract_quarter - , subq_4.visit__ds__extract_month - , subq_4.visit__ds__extract_day - , subq_4.visit__ds__extract_dow - , subq_4.visit__ds__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.user - , subq_4.session - , subq_4.visit__user - , subq_4.visit__session - , subq_4.referrer_id - , subq_4.visit__referrer_id - , subq_4.visits - , subq_4.visitors + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -150,179 +150,179 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' + ) subq_2 + ) subq_3 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 + ) subq_4 GROUP BY - subq_8.metric_time__day - , subq_8.visit__referrer_id - ) subq_9 + subq_4.metric_time__day + , subq_4.visit__referrer_id + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_19.metric_time__day - , subq_19.visit__referrer_id - , SUM(subq_19.buys) AS buys + subq_15.metric_time__day + , subq_15.visit__referrer_id + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_18.metric_time__day - , subq_18.visit__referrer_id - , subq_18.buys + subq_14.metric_time__day + , subq_14.visit__referrer_id + , subq_14.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_17.ds__day - , subq_17.metric_time__day - , subq_17.user - , subq_17.visit__referrer_id - , subq_17.buys - , subq_17.visits + subq_13.ds__day + , subq_13.metric_time__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_13.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_13.visit__referrer_id) OVER ( + , first_value(subq_9.visit__referrer_id) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_13.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_13.metric_time__day) OVER ( + , first_value(subq_9.metric_time__day) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , first_value(subq_13.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_16.user - , subq_16.ds__day - , subq_16.mf_internal_uuid - ORDER BY subq_13.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_16.mf_internal_uuid AS mf_internal_uuid - , subq_16.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user'] SELECT - subq_12.ds__day - , subq_12.metric_time__day - , subq_12.user - , subq_12.visit__referrer_id - , subq_12.visits + subq_8.ds__day + , subq_8.metric_time__day + , subq_8.user + , subq_8.visit__referrer_id + , subq_8.visits FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.visit__ds__day - , subq_11.visit__ds__week - , subq_11.visit__ds__month - , subq_11.visit__ds__quarter - , subq_11.visit__ds__year - , subq_11.visit__ds__extract_year - , subq_11.visit__ds__extract_quarter - , subq_11.visit__ds__extract_month - , subq_11.visit__ds__extract_day - , subq_11.visit__ds__extract_dow - , subq_11.visit__ds__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session - , subq_11.visit__user - , subq_11.visit__session - , subq_11.referrer_id - , subq_11.visit__referrer_id - , subq_11.visits - , subq_11.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__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.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors 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.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__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.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + 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.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__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.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -357,96 +357,96 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' - ) subq_12 - ) subq_13 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.buy__ds__day - , subq_15.buy__ds__week - , subq_15.buy__ds__month - , subq_15.buy__ds__quarter - , subq_15.buy__ds__year - , subq_15.buy__ds__extract_year - , subq_15.buy__ds__extract_quarter - , subq_15.buy__ds__extract_month - , subq_15.buy__ds__extract_day - , subq_15.buy__ds__extract_dow - , subq_15.buy__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.user - , subq_15.session_id - , subq_15.buy__user - , subq_15.buy__session_id - , subq_15.buys - , subq_15.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , uuid() AS mf_internal_uuid 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.buy__ds__day - , subq_14.buy__ds__week - , subq_14.buy__ds__month - , subq_14.buy__ds__quarter - , subq_14.buy__ds__year - , subq_14.buy__ds__extract_year - , subq_14.buy__ds__extract_quarter - , subq_14.buy__ds__extract_month - , subq_14.buy__ds__extract_day - , subq_14.buy__ds__extract_dow - , subq_14.buy__ds__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.user - , subq_14.session_id - , subq_14.buy__user - , subq_14.buy__session_id - , subq_14.buys - , subq_14.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -479,33 +479,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_13.user = subq_16.user + subq_9.user = subq_12.user ) AND ( ( - subq_13.ds__day <= subq_16.ds__day + subq_9.ds__day <= subq_12.ds__day ) AND ( - subq_13.ds__day > DATE_ADD('day', -7, subq_16.ds__day) + subq_9.ds__day > DATE_ADD('day', -7, subq_12.ds__day) ) ) - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY - subq_19.metric_time__day - , subq_19.visit__referrer_id - ) subq_20 + subq_15.metric_time__day + , subq_15.visit__referrer_id + ) subq_16 ON ( - subq_9.visit__referrer_id = subq_20.visit__referrer_id + subq_5.visit__referrer_id = subq_16.visit__referrer_id ) AND ( - subq_9.metric_time__day = subq_20.metric_time__day + subq_5.metric_time__day = subq_16.metric_time__day ) GROUP BY - COALESCE(subq_9.metric_time__day, subq_20.metric_time__day) - , COALESCE(subq_9.visit__referrer_id, subq_20.visit__referrer_id) -) subq_21 + COALESCE(subq_5.metric_time__day, subq_16.metric_time__day) + , COALESCE(subq_5.visit__referrer_id, subq_16.visit__referrer_id) +) subq_17 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql index 8ee8975228..f1cf6c745c 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.metric_time__day, subq_42.metric_time__day) AS metric_time__day - , COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) AS visit__referrer_id - , MAX(subq_31.visits) AS visits - , MAX(subq_42.buys) AS buys + COALESCE(subq_23.metric_time__day, subq_34.metric_time__day) AS metric_time__day + , COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) AS visit__referrer_id + , MAX(subq_23.visits) AS visits + , MAX(subq_34.buys) AS buys FROM ( -- Constrain Output with WHERE -- Aggregate Measures @@ -28,12 +28,12 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' - ) subq_29 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day , visit__referrer_id - ) subq_31 + ) subq_23 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day'] @@ -45,48 +45,48 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_35.visits) OVER ( + first_value(subq_27.visits) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_35.visit__referrer_id) OVER ( + , first_value(subq_27.visit__referrer_id) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , first_value(subq_35.ds__day) OVER ( + , first_value(subq_27.ds__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_35.metric_time__day) OVER ( + , first_value(subq_27.metric_time__day) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , first_value(subq_35.user) OVER ( + , first_value(subq_27.user) OVER ( PARTITION BY - subq_38.user - , subq_38.ds__day - , subq_38.mf_internal_uuid - ORDER BY subq_35.ds__day DESC + subq_30.user + , subq_30.ds__day + , subq_30.mf_internal_uuid + ORDER BY subq_27.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_38.mf_internal_uuid AS mf_internal_uuid - , subq_38.buys AS buys + , subq_30.mf_internal_uuid AS mf_internal_uuid + , subq_30.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -100,7 +100,7 @@ FROM ( , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' - ) subq_35 + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -111,29 +111,29 @@ FROM ( , 1 AS buys , uuid() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_38 + ) subq_30 ON ( - subq_35.user = subq_38.user + subq_27.user = subq_30.user ) AND ( ( - subq_35.ds__day <= subq_38.ds__day + subq_27.ds__day <= subq_30.ds__day ) AND ( - subq_35.ds__day > DATE_ADD('day', -7, subq_38.ds__day) + subq_27.ds__day > DATE_ADD('day', -7, subq_30.ds__day) ) ) - ) subq_39 + ) subq_31 GROUP BY metric_time__day , visit__referrer_id - ) subq_42 + ) subq_34 ON ( - subq_31.visit__referrer_id = subq_42.visit__referrer_id + subq_23.visit__referrer_id = subq_34.visit__referrer_id ) AND ( - subq_31.metric_time__day = subq_42.metric_time__day + subq_23.metric_time__day = subq_34.metric_time__day ) GROUP BY - COALESCE(subq_31.metric_time__day, subq_42.metric_time__day) - , COALESCE(subq_31.visit__referrer_id, subq_42.visit__referrer_id) -) subq_43 + COALESCE(subq_23.metric_time__day, subq_34.metric_time__day) + , COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) +) subq_35 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_month__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_month__plan0.sql index e52ecffc47..b1d0193e5e 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_month__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_month__plan0.sql @@ -1,103 +1,103 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month - , subq_10.bookings_monthly AS trailing_3_months_bookings + subq_8.metric_time__month + , subq_8.bookings_monthly AS trailing_3_months_bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__month - , SUM(subq_9.bookings_monthly) AS bookings_monthly + subq_7.metric_time__month + , SUM(subq_7.bookings_monthly) AS bookings_monthly FROM ( -- Constrain Time Range to [2020-03-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_8.metric_time__month - , subq_8.bookings_monthly + subq_6.metric_time__month + , subq_6.bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_7.metric_time__month - , subq_7.bookings_monthly + subq_5.metric_time__month + , subq_5.bookings_monthly FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__month AS metric_time__month - , subq_4.monthly_ds__month AS monthly_ds__month - , subq_4.monthly_ds__quarter AS monthly_ds__quarter - , subq_4.monthly_ds__year AS monthly_ds__year - , subq_4.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_4.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_4.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_4.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_4.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_4.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_4.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_4.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_4.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.listing AS listing - , subq_4.booking__listing AS booking__listing - , subq_4.bookings_monthly AS bookings_monthly + subq_3.metric_time__month AS metric_time__month + , subq_2.monthly_ds__month AS monthly_ds__month + , subq_2.monthly_ds__quarter AS monthly_ds__quarter + , subq_2.monthly_ds__year AS monthly_ds__year + , subq_2.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_2.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_2.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_2.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_2.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_2.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_2.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_2.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_2.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.listing AS listing + , subq_2.booking__listing AS booking__listing + , subq_2.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATETIME_TRUNC(subq_6.ds, month) AS metric_time__month - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-03-05' AND '2021-01-04' + DATETIME_TRUNC(subq_4.ds, month) AS metric_time__month + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY metric_time__month - ) subq_5 + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-12-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_3.monthly_ds__month - , subq_3.monthly_ds__quarter - , subq_3.monthly_ds__year - , subq_3.monthly_ds__extract_year - , subq_3.monthly_ds__extract_quarter - , subq_3.monthly_ds__extract_month - , subq_3.booking__monthly_ds__month - , subq_3.booking__monthly_ds__quarter - , subq_3.booking__monthly_ds__year - , subq_3.booking__monthly_ds__extract_year - , subq_3.booking__monthly_ds__extract_quarter - , subq_3.booking__monthly_ds__extract_month - , 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.listing - , subq_3.booking__listing - , subq_3.bookings_monthly + subq_1.monthly_ds__month + , subq_1.monthly_ds__quarter + , subq_1.monthly_ds__year + , subq_1.monthly_ds__extract_year + , subq_1.monthly_ds__extract_quarter + , subq_1.monthly_ds__extract_month + , subq_1.booking__monthly_ds__month + , subq_1.booking__monthly_ds__quarter + , subq_1.booking__monthly_ds__year + , subq_1.booking__monthly_ds__extract_year + , subq_1.booking__monthly_ds__extract_quarter + , subq_1.booking__monthly_ds__extract_month + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.listing + , subq_1.booking__listing + , subq_1.bookings_monthly FROM ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_2.monthly_ds__month - , subq_2.monthly_ds__quarter - , subq_2.monthly_ds__year - , subq_2.monthly_ds__extract_year - , subq_2.monthly_ds__extract_quarter - , subq_2.monthly_ds__extract_month - , subq_2.booking__monthly_ds__month - , subq_2.booking__monthly_ds__quarter - , subq_2.booking__monthly_ds__year - , subq_2.booking__monthly_ds__extract_year - , subq_2.booking__monthly_ds__extract_quarter - , subq_2.booking__monthly_ds__extract_month - , subq_2.monthly_ds__month AS metric_time__month - , subq_2.monthly_ds__quarter AS metric_time__quarter - , subq_2.monthly_ds__year AS metric_time__year - , subq_2.monthly_ds__extract_year AS metric_time__extract_year - , subq_2.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_2.monthly_ds__extract_month AS metric_time__extract_month - , subq_2.listing - , subq_2.booking__listing - , subq_2.bookings_monthly + subq_0.monthly_ds__month + , subq_0.monthly_ds__quarter + , subq_0.monthly_ds__year + , subq_0.monthly_ds__extract_year + , subq_0.monthly_ds__extract_quarter + , subq_0.monthly_ds__extract_month + , subq_0.booking__monthly_ds__month + , subq_0.booking__monthly_ds__quarter + , subq_0.booking__monthly_ds__year + , subq_0.booking__monthly_ds__extract_year + , subq_0.booking__monthly_ds__extract_quarter + , subq_0.booking__monthly_ds__extract_month + , subq_0.monthly_ds__month AS metric_time__month + , subq_0.monthly_ds__quarter AS metric_time__quarter + , subq_0.monthly_ds__year AS metric_time__year + , subq_0.monthly_ds__extract_year AS metric_time__extract_year + , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.monthly_ds__extract_month AS metric_time__extract_month + , subq_0.listing + , subq_0.booking__listing + , subq_0.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -117,20 +117,20 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' + ) subq_2 ON ( - subq_4.metric_time__month <= subq_5.metric_time__month + subq_2.metric_time__month <= subq_3.metric_time__month ) AND ( - subq_4.metric_time__month > DATE_SUB(CAST(subq_5.metric_time__month AS DATETIME), INTERVAL 3 month) + subq_2.metric_time__month > DATE_SUB(CAST(subq_3.metric_time__month AS DATETIME), INTERVAL 3 month) ) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' - ) subq_9 + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' + ) subq_7 GROUP BY metric_time__month -) subq_10 +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_month__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_month__plan0_optimized.sql index 50e06298a9..133c390be6 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_month__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_month__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__month AS metric_time__month - , SUM(subq_15.bookings_monthly) AS trailing_3_months_bookings + subq_12.metric_time__month AS metric_time__month + , SUM(subq_11.bookings_monthly) AS trailing_3_months_bookings FROM ( -- Time Spine SELECT DATETIME_TRUNC(ds, month) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY metric_time__month -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_monthly_source' -- Metric Time Dimension 'monthly_ds' @@ -24,13 +24,13 @@ INNER JOIN ( , bookings_monthly FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 WHERE DATETIME_TRUNC(ds, month) BETWEEN '2019-12-05' AND '2021-01-04' -) subq_15 +) subq_11 ON ( - subq_15.metric_time__month <= subq_16.metric_time__month + subq_11.metric_time__month <= subq_12.metric_time__month ) AND ( - subq_15.metric_time__month > DATE_SUB(CAST(subq_16.metric_time__month AS DATETIME), INTERVAL 3 month) + subq_11.metric_time__month > DATE_SUB(CAST(subq_12.metric_time__month AS DATETIME), INTERVAL 3 month) ) -WHERE subq_16.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' +WHERE subq_12.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY metric_time__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index ac6499a90b..feb504cb9f 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -1,148 +1,148 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month - , subq_10.txn_revenue AS revenue_all_time + subq_8.metric_time__month + , subq_8.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__month - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_7.metric_time__month + , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_8.metric_time__month - , subq_8.txn_revenue + subq_6.metric_time__month + , subq_6.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] SELECT - subq_7.metric_time__month - , subq_7.txn_revenue + subq_5.metric_time__month + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__month AS metric_time__month - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_4.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_4.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_4.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_4.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_4.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_4.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_4.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_4.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_4.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_4.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.user AS user - , subq_4.revenue_instance__user AS revenue_instance__user - , subq_4.txn_revenue AS txn_revenue + subq_3.metric_time__month AS metric_time__month + , 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.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_2.metric_time__day AS metric_time__day + , subq_2.metric_time__week AS metric_time__week + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.metric_time__extract_day AS metric_time__extract_day + , subq_2.metric_time__extract_dow AS metric_time__extract_dow + , subq_2.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.user AS user + , subq_2.revenue_instance__user AS revenue_instance__user + , subq_2.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - DATETIME_TRUNC(subq_6.ds, month) AS metric_time__month - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-01-01' AND '2020-01-01' + DATETIME_TRUNC(subq_4.ds, month) AS metric_time__month + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY metric_time__month - ) subq_5 + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] 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.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__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.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue + 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.revenue_instance__ds__day + , subq_1.revenue_instance__ds__week + , subq_1.revenue_instance__ds__month + , subq_1.revenue_instance__ds__quarter + , subq_1.revenue_instance__ds__year + , subq_1.revenue_instance__ds__extract_year + , subq_1.revenue_instance__ds__extract_quarter + , subq_1.revenue_instance__ds__extract_month + , subq_1.revenue_instance__ds__extract_day + , subq_1.revenue_instance__ds__extract_dow + , subq_1.revenue_instance__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.revenue_instance__user + , subq_1.txn_revenue 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.revenue_instance__ds__day - , subq_2.revenue_instance__ds__week - , subq_2.revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__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.user - , subq_2.revenue_instance__user - , subq_2.txn_revenue + 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.revenue_instance__ds__day + , subq_0.revenue_instance__ds__week + , subq_0.revenue_instance__ds__month + , subq_0.revenue_instance__ds__quarter + , subq_0.revenue_instance__ds__year + , subq_0.revenue_instance__ds__extract_year + , subq_0.revenue_instance__ds__extract_quarter + , subq_0.revenue_instance__ds__extract_month + , subq_0.revenue_instance__ds__extract_day + , subq_0.revenue_instance__ds__extract_dow + , subq_0.revenue_instance__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.revenue_instance__user + , subq_0.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -172,16 +172,16 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' + ) subq_2 ON - (subq_4.metric_time__month <= subq_5.metric_time__month) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_9 + (subq_2.metric_time__month <= subq_3.metric_time__month) + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_7 GROUP BY metric_time__month -) subq_10 +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 1abc38a764..b251ad819f 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__month AS metric_time__month - , SUM(subq_15.txn_revenue) AS revenue_all_time + subq_12.metric_time__month AS metric_time__month + , SUM(subq_11.txn_revenue) AS revenue_all_time FROM ( -- Time Spine SELECT DATETIME_TRUNC(ds, month) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY metric_time__month -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -24,9 +24,9 @@ INNER JOIN ( , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_28000 WHERE DATETIME_TRUNC(created_at, day) BETWEEN '2000-01-01' AND '2020-01-01' -) subq_15 +) subq_11 ON - (subq_15.metric_time__month <= subq_16.metric_time__month) -WHERE subq_16.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + (subq_11.metric_time__month <= subq_12.metric_time__month) +WHERE subq_12.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY metric_time__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql index 5bca01c1be..0fb334ddbe 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql @@ -1,146 +1,146 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.txn_revenue AS trailing_2_months_revenue + subq_8.metric_time__day + , subq_8.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_7.metric_time__day + , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_8.metric_time__day - , subq_8.txn_revenue + subq_6.metric_time__day + , subq_6.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.txn_revenue + subq_5.metric_time__day + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_4.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_4.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_4.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_4.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_4.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_4.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_4.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_4.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_4.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_4.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.user AS user - , subq_4.revenue_instance__user AS revenue_instance__user - , subq_4.txn_revenue AS txn_revenue + subq_3.metric_time__day AS metric_time__day + , 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.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_2.metric_time__week AS metric_time__week + , subq_2.metric_time__month AS metric_time__month + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.metric_time__extract_day AS metric_time__extract_day + , subq_2.metric_time__extract_dow AS metric_time__extract_dow + , subq_2.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.user AS user + , subq_2.revenue_instance__user AS revenue_instance__user + , subq_2.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_5 + subq_4.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] 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.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__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.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue + 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.revenue_instance__ds__day + , subq_1.revenue_instance__ds__week + , subq_1.revenue_instance__ds__month + , subq_1.revenue_instance__ds__quarter + , subq_1.revenue_instance__ds__year + , subq_1.revenue_instance__ds__extract_year + , subq_1.revenue_instance__ds__extract_quarter + , subq_1.revenue_instance__ds__extract_month + , subq_1.revenue_instance__ds__extract_day + , subq_1.revenue_instance__ds__extract_dow + , subq_1.revenue_instance__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.revenue_instance__user + , subq_1.txn_revenue 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.revenue_instance__ds__day - , subq_2.revenue_instance__ds__week - , subq_2.revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__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.user - , subq_2.revenue_instance__user - , subq_2.txn_revenue + 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.revenue_instance__ds__day + , subq_0.revenue_instance__ds__week + , subq_0.revenue_instance__ds__month + , subq_0.revenue_instance__ds__quarter + , subq_0.revenue_instance__ds__year + , subq_0.revenue_instance__ds__extract_year + , subq_0.revenue_instance__ds__extract_quarter + , subq_0.revenue_instance__ds__extract_month + , subq_0.revenue_instance__ds__extract_day + , subq_0.revenue_instance__ds__extract_dow + , subq_0.revenue_instance__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.revenue_instance__user + , subq_0.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -170,20 +170,20 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' + ) subq_2 ON ( - subq_4.metric_time__day <= subq_5.metric_time__day + subq_2.metric_time__day <= subq_3.metric_time__day ) AND ( - subq_4.metric_time__day > DATE_SUB(CAST(subq_5.metric_time__day AS DATETIME), INTERVAL 2 month) + subq_2.metric_time__day > DATE_SUB(CAST(subq_3.metric_time__day AS DATETIME), INTERVAL 2 month) ) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_9 + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_7 GROUP BY metric_time__day -) subq_10 +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 7a8747d7fa..88ef795b84 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -4,15 +4,15 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , SUM(subq_15.txn_revenue) AS trailing_2_months_revenue + subq_12.metric_time__day AS metric_time__day + , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -22,13 +22,13 @@ INNER JOIN ( , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_28000 WHERE DATETIME_TRUNC(created_at, day) BETWEEN '2019-11-01' AND '2020-01-01' -) subq_15 +) subq_11 ON ( - subq_15.metric_time__day <= subq_16.metric_time__day + subq_11.metric_time__day <= subq_12.metric_time__day ) AND ( - subq_15.metric_time__day > DATE_SUB(CAST(subq_16.metric_time__day AS DATETIME), INTERVAL 2 month) + subq_11.metric_time__day > DATE_SUB(CAST(subq_12.metric_time__day AS DATETIME), INTERVAL 2 month) ) -WHERE subq_16.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' +WHERE subq_12.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_month__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_month__plan0.sql index 7b5a52155e..5bc9116fc1 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_month__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_month__plan0.sql @@ -1,103 +1,103 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month - , subq_10.bookings_monthly AS trailing_3_months_bookings + subq_8.metric_time__month + , subq_8.bookings_monthly AS trailing_3_months_bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__month - , SUM(subq_9.bookings_monthly) AS bookings_monthly + subq_7.metric_time__month + , SUM(subq_7.bookings_monthly) AS bookings_monthly FROM ( -- Constrain Time Range to [2020-03-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_8.metric_time__month - , subq_8.bookings_monthly + subq_6.metric_time__month + , subq_6.bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_7.metric_time__month - , subq_7.bookings_monthly + subq_5.metric_time__month + , subq_5.bookings_monthly FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__month AS metric_time__month - , subq_4.monthly_ds__month AS monthly_ds__month - , subq_4.monthly_ds__quarter AS monthly_ds__quarter - , subq_4.monthly_ds__year AS monthly_ds__year - , subq_4.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_4.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_4.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_4.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_4.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_4.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_4.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_4.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_4.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.listing AS listing - , subq_4.booking__listing AS booking__listing - , subq_4.bookings_monthly AS bookings_monthly + subq_3.metric_time__month AS metric_time__month + , subq_2.monthly_ds__month AS monthly_ds__month + , subq_2.monthly_ds__quarter AS monthly_ds__quarter + , subq_2.monthly_ds__year AS monthly_ds__year + , subq_2.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_2.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_2.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_2.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_2.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_2.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_2.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_2.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_2.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.listing AS listing + , subq_2.booking__listing AS booking__listing + , subq_2.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_6.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-03-05' AND '2021-01-04' + DATE_TRUNC('month', subq_4.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - DATE_TRUNC('month', subq_6.ds) - ) subq_5 + DATE_TRUNC('month', subq_4.ds) + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-12-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_3.monthly_ds__month - , subq_3.monthly_ds__quarter - , subq_3.monthly_ds__year - , subq_3.monthly_ds__extract_year - , subq_3.monthly_ds__extract_quarter - , subq_3.monthly_ds__extract_month - , subq_3.booking__monthly_ds__month - , subq_3.booking__monthly_ds__quarter - , subq_3.booking__monthly_ds__year - , subq_3.booking__monthly_ds__extract_year - , subq_3.booking__monthly_ds__extract_quarter - , subq_3.booking__monthly_ds__extract_month - , 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.listing - , subq_3.booking__listing - , subq_3.bookings_monthly + subq_1.monthly_ds__month + , subq_1.monthly_ds__quarter + , subq_1.monthly_ds__year + , subq_1.monthly_ds__extract_year + , subq_1.monthly_ds__extract_quarter + , subq_1.monthly_ds__extract_month + , subq_1.booking__monthly_ds__month + , subq_1.booking__monthly_ds__quarter + , subq_1.booking__monthly_ds__year + , subq_1.booking__monthly_ds__extract_year + , subq_1.booking__monthly_ds__extract_quarter + , subq_1.booking__monthly_ds__extract_month + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.listing + , subq_1.booking__listing + , subq_1.bookings_monthly FROM ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_2.monthly_ds__month - , subq_2.monthly_ds__quarter - , subq_2.monthly_ds__year - , subq_2.monthly_ds__extract_year - , subq_2.monthly_ds__extract_quarter - , subq_2.monthly_ds__extract_month - , subq_2.booking__monthly_ds__month - , subq_2.booking__monthly_ds__quarter - , subq_2.booking__monthly_ds__year - , subq_2.booking__monthly_ds__extract_year - , subq_2.booking__monthly_ds__extract_quarter - , subq_2.booking__monthly_ds__extract_month - , subq_2.monthly_ds__month AS metric_time__month - , subq_2.monthly_ds__quarter AS metric_time__quarter - , subq_2.monthly_ds__year AS metric_time__year - , subq_2.monthly_ds__extract_year AS metric_time__extract_year - , subq_2.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_2.monthly_ds__extract_month AS metric_time__extract_month - , subq_2.listing - , subq_2.booking__listing - , subq_2.bookings_monthly + subq_0.monthly_ds__month + , subq_0.monthly_ds__quarter + , subq_0.monthly_ds__year + , subq_0.monthly_ds__extract_year + , subq_0.monthly_ds__extract_quarter + , subq_0.monthly_ds__extract_month + , subq_0.booking__monthly_ds__month + , subq_0.booking__monthly_ds__quarter + , subq_0.booking__monthly_ds__year + , subq_0.booking__monthly_ds__extract_year + , subq_0.booking__monthly_ds__extract_quarter + , subq_0.booking__monthly_ds__extract_month + , subq_0.monthly_ds__month AS metric_time__month + , subq_0.monthly_ds__quarter AS metric_time__quarter + , subq_0.monthly_ds__year AS metric_time__year + , subq_0.monthly_ds__extract_year AS metric_time__extract_year + , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.monthly_ds__extract_month AS metric_time__extract_month + , subq_0.listing + , subq_0.booking__listing + , subq_0.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -117,20 +117,20 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' + ) subq_2 ON ( - subq_4.metric_time__month <= subq_5.metric_time__month + subq_2.metric_time__month <= subq_3.metric_time__month ) AND ( - subq_4.metric_time__month > DATEADD(month, -3, subq_5.metric_time__month) + subq_2.metric_time__month > DATEADD(month, -3, subq_3.metric_time__month) ) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' - ) subq_9 + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' + ) subq_7 GROUP BY - subq_9.metric_time__month -) subq_10 + subq_7.metric_time__month +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_month__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_month__plan0_optimized.sql index c9b1da3166..4611f8316c 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_month__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_month__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__month AS metric_time__month - , SUM(subq_15.bookings_monthly) AS trailing_3_months_bookings + subq_12.metric_time__month AS metric_time__month + , SUM(subq_11.bookings_monthly) AS trailing_3_months_bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY DATE_TRUNC('month', ds) -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_monthly_source' -- Metric Time Dimension 'monthly_ds' @@ -24,13 +24,13 @@ INNER JOIN ( , bookings_monthly FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 WHERE DATE_TRUNC('month', ds) BETWEEN '2019-12-05' AND '2021-01-04' -) subq_15 +) subq_11 ON ( - subq_15.metric_time__month <= subq_16.metric_time__month + subq_11.metric_time__month <= subq_12.metric_time__month ) AND ( - subq_15.metric_time__month > DATEADD(month, -3, subq_16.metric_time__month) + subq_11.metric_time__month > DATEADD(month, -3, subq_12.metric_time__month) ) -WHERE subq_16.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' +WHERE subq_12.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - subq_16.metric_time__month + subq_12.metric_time__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index f8e061a68a..4fe38e1ff2 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -1,148 +1,148 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month - , subq_10.txn_revenue AS revenue_all_time + subq_8.metric_time__month + , subq_8.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__month - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_7.metric_time__month + , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_8.metric_time__month - , subq_8.txn_revenue + subq_6.metric_time__month + , subq_6.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] SELECT - subq_7.metric_time__month - , subq_7.txn_revenue + subq_5.metric_time__month + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__month AS metric_time__month - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_4.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_4.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_4.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_4.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_4.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_4.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_4.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_4.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_4.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_4.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.user AS user - , subq_4.revenue_instance__user AS revenue_instance__user - , subq_4.txn_revenue AS txn_revenue + subq_3.metric_time__month AS metric_time__month + , 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.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_2.metric_time__day AS metric_time__day + , subq_2.metric_time__week AS metric_time__week + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.metric_time__extract_day AS metric_time__extract_day + , subq_2.metric_time__extract_dow AS metric_time__extract_dow + , subq_2.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.user AS user + , subq_2.revenue_instance__user AS revenue_instance__user + , subq_2.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_6.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-01-01' AND '2020-01-01' + DATE_TRUNC('month', subq_4.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - DATE_TRUNC('month', subq_6.ds) - ) subq_5 + DATE_TRUNC('month', subq_4.ds) + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] 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.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__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.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue + 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.revenue_instance__ds__day + , subq_1.revenue_instance__ds__week + , subq_1.revenue_instance__ds__month + , subq_1.revenue_instance__ds__quarter + , subq_1.revenue_instance__ds__year + , subq_1.revenue_instance__ds__extract_year + , subq_1.revenue_instance__ds__extract_quarter + , subq_1.revenue_instance__ds__extract_month + , subq_1.revenue_instance__ds__extract_day + , subq_1.revenue_instance__ds__extract_dow + , subq_1.revenue_instance__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.revenue_instance__user + , subq_1.txn_revenue 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.revenue_instance__ds__day - , subq_2.revenue_instance__ds__week - , subq_2.revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__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.user - , subq_2.revenue_instance__user - , subq_2.txn_revenue + 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.revenue_instance__ds__day + , subq_0.revenue_instance__ds__week + , subq_0.revenue_instance__ds__month + , subq_0.revenue_instance__ds__quarter + , subq_0.revenue_instance__ds__year + , subq_0.revenue_instance__ds__extract_year + , subq_0.revenue_instance__ds__extract_quarter + , subq_0.revenue_instance__ds__extract_month + , subq_0.revenue_instance__ds__extract_day + , subq_0.revenue_instance__ds__extract_dow + , subq_0.revenue_instance__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.revenue_instance__user + , subq_0.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -172,16 +172,16 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' + ) subq_2 ON - (subq_4.metric_time__month <= subq_5.metric_time__month) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_9 + (subq_2.metric_time__month <= subq_3.metric_time__month) + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_7 GROUP BY - subq_9.metric_time__month -) subq_10 + subq_7.metric_time__month +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 30ac0eed55..02e630aa1e 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__month AS metric_time__month - , SUM(subq_15.txn_revenue) AS revenue_all_time + subq_12.metric_time__month AS metric_time__month + , SUM(subq_11.txn_revenue) AS revenue_all_time FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', ds) -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -24,9 +24,9 @@ INNER JOIN ( , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' -) subq_15 +) subq_11 ON - (subq_15.metric_time__month <= subq_16.metric_time__month) -WHERE subq_16.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + (subq_11.metric_time__month <= subq_12.metric_time__month) +WHERE subq_12.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_16.metric_time__month + subq_12.metric_time__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql index a34017e763..d8233fe4a6 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql @@ -1,146 +1,146 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.txn_revenue AS trailing_2_months_revenue + subq_8.metric_time__day + , subq_8.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_7.metric_time__day + , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_8.metric_time__day - , subq_8.txn_revenue + subq_6.metric_time__day + , subq_6.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.txn_revenue + subq_5.metric_time__day + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_4.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_4.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_4.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_4.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_4.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_4.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_4.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_4.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_4.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_4.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.user AS user - , subq_4.revenue_instance__user AS revenue_instance__user - , subq_4.txn_revenue AS txn_revenue + subq_3.metric_time__day AS metric_time__day + , 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.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_2.metric_time__week AS metric_time__week + , subq_2.metric_time__month AS metric_time__month + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.metric_time__extract_day AS metric_time__extract_day + , subq_2.metric_time__extract_dow AS metric_time__extract_dow + , subq_2.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.user AS user + , subq_2.revenue_instance__user AS revenue_instance__user + , subq_2.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_5 + subq_4.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] 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.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__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.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue + 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.revenue_instance__ds__day + , subq_1.revenue_instance__ds__week + , subq_1.revenue_instance__ds__month + , subq_1.revenue_instance__ds__quarter + , subq_1.revenue_instance__ds__year + , subq_1.revenue_instance__ds__extract_year + , subq_1.revenue_instance__ds__extract_quarter + , subq_1.revenue_instance__ds__extract_month + , subq_1.revenue_instance__ds__extract_day + , subq_1.revenue_instance__ds__extract_dow + , subq_1.revenue_instance__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.revenue_instance__user + , subq_1.txn_revenue 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.revenue_instance__ds__day - , subq_2.revenue_instance__ds__week - , subq_2.revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__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.user - , subq_2.revenue_instance__user - , subq_2.txn_revenue + 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.revenue_instance__ds__day + , subq_0.revenue_instance__ds__week + , subq_0.revenue_instance__ds__month + , subq_0.revenue_instance__ds__quarter + , subq_0.revenue_instance__ds__year + , subq_0.revenue_instance__ds__extract_year + , subq_0.revenue_instance__ds__extract_quarter + , subq_0.revenue_instance__ds__extract_month + , subq_0.revenue_instance__ds__extract_day + , subq_0.revenue_instance__ds__extract_dow + , subq_0.revenue_instance__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.revenue_instance__user + , subq_0.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -170,20 +170,20 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' + ) subq_2 ON ( - subq_4.metric_time__day <= subq_5.metric_time__day + subq_2.metric_time__day <= subq_3.metric_time__day ) AND ( - subq_4.metric_time__day > DATEADD(month, -2, subq_5.metric_time__day) + subq_2.metric_time__day > DATEADD(month, -2, subq_3.metric_time__day) ) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_9 + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_7 GROUP BY - subq_9.metric_time__day -) subq_10 + subq_7.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index cc5537b0c9..cd4811e1ab 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -4,15 +4,15 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , SUM(subq_15.txn_revenue) AS trailing_2_months_revenue + subq_12.metric_time__day AS metric_time__day + , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -22,13 +22,13 @@ INNER JOIN ( , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' -) subq_15 +) subq_11 ON ( - subq_15.metric_time__day <= subq_16.metric_time__day + subq_11.metric_time__day <= subq_12.metric_time__day ) AND ( - subq_15.metric_time__day > DATEADD(month, -2, subq_16.metric_time__day) + subq_11.metric_time__day > DATEADD(month, -2, subq_12.metric_time__day) ) -WHERE subq_16.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' +WHERE subq_12.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_16.metric_time__day + subq_12.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_month__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_month__plan0.sql index 108251eb4c..8c30047781 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_month__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_month__plan0.sql @@ -1,103 +1,103 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month - , subq_10.bookings_monthly AS trailing_3_months_bookings + subq_8.metric_time__month + , subq_8.bookings_monthly AS trailing_3_months_bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__month - , SUM(subq_9.bookings_monthly) AS bookings_monthly + subq_7.metric_time__month + , SUM(subq_7.bookings_monthly) AS bookings_monthly FROM ( -- Constrain Time Range to [2020-03-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_8.metric_time__month - , subq_8.bookings_monthly + subq_6.metric_time__month + , subq_6.bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_7.metric_time__month - , subq_7.bookings_monthly + subq_5.metric_time__month + , subq_5.bookings_monthly FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__month AS metric_time__month - , subq_4.monthly_ds__month AS monthly_ds__month - , subq_4.monthly_ds__quarter AS monthly_ds__quarter - , subq_4.monthly_ds__year AS monthly_ds__year - , subq_4.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_4.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_4.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_4.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_4.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_4.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_4.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_4.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_4.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.listing AS listing - , subq_4.booking__listing AS booking__listing - , subq_4.bookings_monthly AS bookings_monthly + subq_3.metric_time__month AS metric_time__month + , subq_2.monthly_ds__month AS monthly_ds__month + , subq_2.monthly_ds__quarter AS monthly_ds__quarter + , subq_2.monthly_ds__year AS monthly_ds__year + , subq_2.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_2.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_2.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_2.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_2.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_2.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_2.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_2.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_2.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.listing AS listing + , subq_2.booking__listing AS booking__listing + , subq_2.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_6.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-03-05' AND '2021-01-04' + DATE_TRUNC('month', subq_4.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - DATE_TRUNC('month', subq_6.ds) - ) subq_5 + DATE_TRUNC('month', subq_4.ds) + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-12-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_3.monthly_ds__month - , subq_3.monthly_ds__quarter - , subq_3.monthly_ds__year - , subq_3.monthly_ds__extract_year - , subq_3.monthly_ds__extract_quarter - , subq_3.monthly_ds__extract_month - , subq_3.booking__monthly_ds__month - , subq_3.booking__monthly_ds__quarter - , subq_3.booking__monthly_ds__year - , subq_3.booking__monthly_ds__extract_year - , subq_3.booking__monthly_ds__extract_quarter - , subq_3.booking__monthly_ds__extract_month - , 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.listing - , subq_3.booking__listing - , subq_3.bookings_monthly + subq_1.monthly_ds__month + , subq_1.monthly_ds__quarter + , subq_1.monthly_ds__year + , subq_1.monthly_ds__extract_year + , subq_1.monthly_ds__extract_quarter + , subq_1.monthly_ds__extract_month + , subq_1.booking__monthly_ds__month + , subq_1.booking__monthly_ds__quarter + , subq_1.booking__monthly_ds__year + , subq_1.booking__monthly_ds__extract_year + , subq_1.booking__monthly_ds__extract_quarter + , subq_1.booking__monthly_ds__extract_month + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.listing + , subq_1.booking__listing + , subq_1.bookings_monthly FROM ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_2.monthly_ds__month - , subq_2.monthly_ds__quarter - , subq_2.monthly_ds__year - , subq_2.monthly_ds__extract_year - , subq_2.monthly_ds__extract_quarter - , subq_2.monthly_ds__extract_month - , subq_2.booking__monthly_ds__month - , subq_2.booking__monthly_ds__quarter - , subq_2.booking__monthly_ds__year - , subq_2.booking__monthly_ds__extract_year - , subq_2.booking__monthly_ds__extract_quarter - , subq_2.booking__monthly_ds__extract_month - , subq_2.monthly_ds__month AS metric_time__month - , subq_2.monthly_ds__quarter AS metric_time__quarter - , subq_2.monthly_ds__year AS metric_time__year - , subq_2.monthly_ds__extract_year AS metric_time__extract_year - , subq_2.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_2.monthly_ds__extract_month AS metric_time__extract_month - , subq_2.listing - , subq_2.booking__listing - , subq_2.bookings_monthly + subq_0.monthly_ds__month + , subq_0.monthly_ds__quarter + , subq_0.monthly_ds__year + , subq_0.monthly_ds__extract_year + , subq_0.monthly_ds__extract_quarter + , subq_0.monthly_ds__extract_month + , subq_0.booking__monthly_ds__month + , subq_0.booking__monthly_ds__quarter + , subq_0.booking__monthly_ds__year + , subq_0.booking__monthly_ds__extract_year + , subq_0.booking__monthly_ds__extract_quarter + , subq_0.booking__monthly_ds__extract_month + , subq_0.monthly_ds__month AS metric_time__month + , subq_0.monthly_ds__quarter AS metric_time__quarter + , subq_0.monthly_ds__year AS metric_time__year + , subq_0.monthly_ds__extract_year AS metric_time__extract_year + , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.monthly_ds__extract_month AS metric_time__extract_month + , subq_0.listing + , subq_0.booking__listing + , subq_0.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -117,20 +117,20 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' + ) subq_2 ON ( - subq_4.metric_time__month <= subq_5.metric_time__month + subq_2.metric_time__month <= subq_3.metric_time__month ) AND ( - subq_4.metric_time__month > subq_5.metric_time__month - MAKE_INTERVAL(months => 3) + subq_2.metric_time__month > subq_3.metric_time__month - MAKE_INTERVAL(months => 3) ) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' - ) subq_9 + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' + ) subq_7 GROUP BY - subq_9.metric_time__month -) subq_10 + subq_7.metric_time__month +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_month__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_month__plan0_optimized.sql index 59109e02ce..96c1cc7f0b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_month__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_month__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__month AS metric_time__month - , SUM(subq_15.bookings_monthly) AS trailing_3_months_bookings + subq_12.metric_time__month AS metric_time__month + , SUM(subq_11.bookings_monthly) AS trailing_3_months_bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY DATE_TRUNC('month', ds) -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_monthly_source' -- Metric Time Dimension 'monthly_ds' @@ -24,13 +24,13 @@ INNER JOIN ( , bookings_monthly FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 WHERE DATE_TRUNC('month', ds) BETWEEN '2019-12-05' AND '2021-01-04' -) subq_15 +) subq_11 ON ( - subq_15.metric_time__month <= subq_16.metric_time__month + subq_11.metric_time__month <= subq_12.metric_time__month ) AND ( - subq_15.metric_time__month > subq_16.metric_time__month - MAKE_INTERVAL(months => 3) + subq_11.metric_time__month > subq_12.metric_time__month - MAKE_INTERVAL(months => 3) ) -WHERE subq_16.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' +WHERE subq_12.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - subq_16.metric_time__month + subq_12.metric_time__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 92c30e63b0..68e077fc94 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -1,148 +1,148 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month - , subq_10.txn_revenue AS revenue_all_time + subq_8.metric_time__month + , subq_8.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__month - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_7.metric_time__month + , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_8.metric_time__month - , subq_8.txn_revenue + subq_6.metric_time__month + , subq_6.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] SELECT - subq_7.metric_time__month - , subq_7.txn_revenue + subq_5.metric_time__month + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__month AS metric_time__month - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_4.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_4.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_4.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_4.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_4.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_4.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_4.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_4.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_4.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_4.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.user AS user - , subq_4.revenue_instance__user AS revenue_instance__user - , subq_4.txn_revenue AS txn_revenue + subq_3.metric_time__month AS metric_time__month + , 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.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_2.metric_time__day AS metric_time__day + , subq_2.metric_time__week AS metric_time__week + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.metric_time__extract_day AS metric_time__extract_day + , subq_2.metric_time__extract_dow AS metric_time__extract_dow + , subq_2.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.user AS user + , subq_2.revenue_instance__user AS revenue_instance__user + , subq_2.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_6.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-01-01' AND '2020-01-01' + DATE_TRUNC('month', subq_4.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - DATE_TRUNC('month', subq_6.ds) - ) subq_5 + DATE_TRUNC('month', subq_4.ds) + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] 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.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__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.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue + 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.revenue_instance__ds__day + , subq_1.revenue_instance__ds__week + , subq_1.revenue_instance__ds__month + , subq_1.revenue_instance__ds__quarter + , subq_1.revenue_instance__ds__year + , subq_1.revenue_instance__ds__extract_year + , subq_1.revenue_instance__ds__extract_quarter + , subq_1.revenue_instance__ds__extract_month + , subq_1.revenue_instance__ds__extract_day + , subq_1.revenue_instance__ds__extract_dow + , subq_1.revenue_instance__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.revenue_instance__user + , subq_1.txn_revenue 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.revenue_instance__ds__day - , subq_2.revenue_instance__ds__week - , subq_2.revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__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.user - , subq_2.revenue_instance__user - , subq_2.txn_revenue + 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.revenue_instance__ds__day + , subq_0.revenue_instance__ds__week + , subq_0.revenue_instance__ds__month + , subq_0.revenue_instance__ds__quarter + , subq_0.revenue_instance__ds__year + , subq_0.revenue_instance__ds__extract_year + , subq_0.revenue_instance__ds__extract_quarter + , subq_0.revenue_instance__ds__extract_month + , subq_0.revenue_instance__ds__extract_day + , subq_0.revenue_instance__ds__extract_dow + , subq_0.revenue_instance__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.revenue_instance__user + , subq_0.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -172,16 +172,16 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' + ) subq_2 ON - (subq_4.metric_time__month <= subq_5.metric_time__month) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_9 + (subq_2.metric_time__month <= subq_3.metric_time__month) + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_7 GROUP BY - subq_9.metric_time__month -) subq_10 + subq_7.metric_time__month +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 30ac0eed55..02e630aa1e 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__month AS metric_time__month - , SUM(subq_15.txn_revenue) AS revenue_all_time + subq_12.metric_time__month AS metric_time__month + , SUM(subq_11.txn_revenue) AS revenue_all_time FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', ds) -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -24,9 +24,9 @@ INNER JOIN ( , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' -) subq_15 +) subq_11 ON - (subq_15.metric_time__month <= subq_16.metric_time__month) -WHERE subq_16.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + (subq_11.metric_time__month <= subq_12.metric_time__month) +WHERE subq_12.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_16.metric_time__month + subq_12.metric_time__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql index 54ad1cf354..a77410e810 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql @@ -1,146 +1,146 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.txn_revenue AS trailing_2_months_revenue + subq_8.metric_time__day + , subq_8.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_7.metric_time__day + , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_8.metric_time__day - , subq_8.txn_revenue + subq_6.metric_time__day + , subq_6.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.txn_revenue + subq_5.metric_time__day + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_4.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_4.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_4.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_4.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_4.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_4.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_4.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_4.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_4.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_4.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.user AS user - , subq_4.revenue_instance__user AS revenue_instance__user - , subq_4.txn_revenue AS txn_revenue + subq_3.metric_time__day AS metric_time__day + , 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.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_2.metric_time__week AS metric_time__week + , subq_2.metric_time__month AS metric_time__month + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.metric_time__extract_day AS metric_time__extract_day + , subq_2.metric_time__extract_dow AS metric_time__extract_dow + , subq_2.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.user AS user + , subq_2.revenue_instance__user AS revenue_instance__user + , subq_2.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_5 + subq_4.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] 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.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__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.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue + 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.revenue_instance__ds__day + , subq_1.revenue_instance__ds__week + , subq_1.revenue_instance__ds__month + , subq_1.revenue_instance__ds__quarter + , subq_1.revenue_instance__ds__year + , subq_1.revenue_instance__ds__extract_year + , subq_1.revenue_instance__ds__extract_quarter + , subq_1.revenue_instance__ds__extract_month + , subq_1.revenue_instance__ds__extract_day + , subq_1.revenue_instance__ds__extract_dow + , subq_1.revenue_instance__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.revenue_instance__user + , subq_1.txn_revenue 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.revenue_instance__ds__day - , subq_2.revenue_instance__ds__week - , subq_2.revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__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.user - , subq_2.revenue_instance__user - , subq_2.txn_revenue + 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.revenue_instance__ds__day + , subq_0.revenue_instance__ds__week + , subq_0.revenue_instance__ds__month + , subq_0.revenue_instance__ds__quarter + , subq_0.revenue_instance__ds__year + , subq_0.revenue_instance__ds__extract_year + , subq_0.revenue_instance__ds__extract_quarter + , subq_0.revenue_instance__ds__extract_month + , subq_0.revenue_instance__ds__extract_day + , subq_0.revenue_instance__ds__extract_dow + , subq_0.revenue_instance__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.revenue_instance__user + , subq_0.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -170,20 +170,20 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' + ) subq_2 ON ( - subq_4.metric_time__day <= subq_5.metric_time__day + subq_2.metric_time__day <= subq_3.metric_time__day ) AND ( - subq_4.metric_time__day > subq_5.metric_time__day - MAKE_INTERVAL(months => 2) + subq_2.metric_time__day > subq_3.metric_time__day - MAKE_INTERVAL(months => 2) ) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_9 + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_7 GROUP BY - subq_9.metric_time__day -) subq_10 + subq_7.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index af4463bb2d..6df10259be 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -4,15 +4,15 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , SUM(subq_15.txn_revenue) AS trailing_2_months_revenue + subq_12.metric_time__day AS metric_time__day + , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -22,13 +22,13 @@ INNER JOIN ( , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' -) subq_15 +) subq_11 ON ( - subq_15.metric_time__day <= subq_16.metric_time__day + subq_11.metric_time__day <= subq_12.metric_time__day ) AND ( - subq_15.metric_time__day > subq_16.metric_time__day - MAKE_INTERVAL(months => 2) + subq_11.metric_time__day > subq_12.metric_time__day - MAKE_INTERVAL(months => 2) ) -WHERE subq_16.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' +WHERE subq_12.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_16.metric_time__day + subq_12.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_month__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_month__plan0.sql index 7b5a52155e..5bc9116fc1 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_month__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_month__plan0.sql @@ -1,103 +1,103 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month - , subq_10.bookings_monthly AS trailing_3_months_bookings + subq_8.metric_time__month + , subq_8.bookings_monthly AS trailing_3_months_bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__month - , SUM(subq_9.bookings_monthly) AS bookings_monthly + subq_7.metric_time__month + , SUM(subq_7.bookings_monthly) AS bookings_monthly FROM ( -- Constrain Time Range to [2020-03-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_8.metric_time__month - , subq_8.bookings_monthly + subq_6.metric_time__month + , subq_6.bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_7.metric_time__month - , subq_7.bookings_monthly + subq_5.metric_time__month + , subq_5.bookings_monthly FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__month AS metric_time__month - , subq_4.monthly_ds__month AS monthly_ds__month - , subq_4.monthly_ds__quarter AS monthly_ds__quarter - , subq_4.monthly_ds__year AS monthly_ds__year - , subq_4.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_4.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_4.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_4.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_4.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_4.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_4.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_4.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_4.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.listing AS listing - , subq_4.booking__listing AS booking__listing - , subq_4.bookings_monthly AS bookings_monthly + subq_3.metric_time__month AS metric_time__month + , subq_2.monthly_ds__month AS monthly_ds__month + , subq_2.monthly_ds__quarter AS monthly_ds__quarter + , subq_2.monthly_ds__year AS monthly_ds__year + , subq_2.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_2.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_2.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_2.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_2.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_2.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_2.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_2.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_2.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.listing AS listing + , subq_2.booking__listing AS booking__listing + , subq_2.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_6.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-03-05' AND '2021-01-04' + DATE_TRUNC('month', subq_4.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - DATE_TRUNC('month', subq_6.ds) - ) subq_5 + DATE_TRUNC('month', subq_4.ds) + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-12-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_3.monthly_ds__month - , subq_3.monthly_ds__quarter - , subq_3.monthly_ds__year - , subq_3.monthly_ds__extract_year - , subq_3.monthly_ds__extract_quarter - , subq_3.monthly_ds__extract_month - , subq_3.booking__monthly_ds__month - , subq_3.booking__monthly_ds__quarter - , subq_3.booking__monthly_ds__year - , subq_3.booking__monthly_ds__extract_year - , subq_3.booking__monthly_ds__extract_quarter - , subq_3.booking__monthly_ds__extract_month - , 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.listing - , subq_3.booking__listing - , subq_3.bookings_monthly + subq_1.monthly_ds__month + , subq_1.monthly_ds__quarter + , subq_1.monthly_ds__year + , subq_1.monthly_ds__extract_year + , subq_1.monthly_ds__extract_quarter + , subq_1.monthly_ds__extract_month + , subq_1.booking__monthly_ds__month + , subq_1.booking__monthly_ds__quarter + , subq_1.booking__monthly_ds__year + , subq_1.booking__monthly_ds__extract_year + , subq_1.booking__monthly_ds__extract_quarter + , subq_1.booking__monthly_ds__extract_month + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.listing + , subq_1.booking__listing + , subq_1.bookings_monthly FROM ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_2.monthly_ds__month - , subq_2.monthly_ds__quarter - , subq_2.monthly_ds__year - , subq_2.monthly_ds__extract_year - , subq_2.monthly_ds__extract_quarter - , subq_2.monthly_ds__extract_month - , subq_2.booking__monthly_ds__month - , subq_2.booking__monthly_ds__quarter - , subq_2.booking__monthly_ds__year - , subq_2.booking__monthly_ds__extract_year - , subq_2.booking__monthly_ds__extract_quarter - , subq_2.booking__monthly_ds__extract_month - , subq_2.monthly_ds__month AS metric_time__month - , subq_2.monthly_ds__quarter AS metric_time__quarter - , subq_2.monthly_ds__year AS metric_time__year - , subq_2.monthly_ds__extract_year AS metric_time__extract_year - , subq_2.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_2.monthly_ds__extract_month AS metric_time__extract_month - , subq_2.listing - , subq_2.booking__listing - , subq_2.bookings_monthly + subq_0.monthly_ds__month + , subq_0.monthly_ds__quarter + , subq_0.monthly_ds__year + , subq_0.monthly_ds__extract_year + , subq_0.monthly_ds__extract_quarter + , subq_0.monthly_ds__extract_month + , subq_0.booking__monthly_ds__month + , subq_0.booking__monthly_ds__quarter + , subq_0.booking__monthly_ds__year + , subq_0.booking__monthly_ds__extract_year + , subq_0.booking__monthly_ds__extract_quarter + , subq_0.booking__monthly_ds__extract_month + , subq_0.monthly_ds__month AS metric_time__month + , subq_0.monthly_ds__quarter AS metric_time__quarter + , subq_0.monthly_ds__year AS metric_time__year + , subq_0.monthly_ds__extract_year AS metric_time__extract_year + , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.monthly_ds__extract_month AS metric_time__extract_month + , subq_0.listing + , subq_0.booking__listing + , subq_0.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -117,20 +117,20 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' + ) subq_2 ON ( - subq_4.metric_time__month <= subq_5.metric_time__month + subq_2.metric_time__month <= subq_3.metric_time__month ) AND ( - subq_4.metric_time__month > DATEADD(month, -3, subq_5.metric_time__month) + subq_2.metric_time__month > DATEADD(month, -3, subq_3.metric_time__month) ) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' - ) subq_9 + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' + ) subq_7 GROUP BY - subq_9.metric_time__month -) subq_10 + subq_7.metric_time__month +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_month__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_month__plan0_optimized.sql index c9b1da3166..4611f8316c 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_month__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_month__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__month AS metric_time__month - , SUM(subq_15.bookings_monthly) AS trailing_3_months_bookings + subq_12.metric_time__month AS metric_time__month + , SUM(subq_11.bookings_monthly) AS trailing_3_months_bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY DATE_TRUNC('month', ds) -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_monthly_source' -- Metric Time Dimension 'monthly_ds' @@ -24,13 +24,13 @@ INNER JOIN ( , bookings_monthly FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 WHERE DATE_TRUNC('month', ds) BETWEEN '2019-12-05' AND '2021-01-04' -) subq_15 +) subq_11 ON ( - subq_15.metric_time__month <= subq_16.metric_time__month + subq_11.metric_time__month <= subq_12.metric_time__month ) AND ( - subq_15.metric_time__month > DATEADD(month, -3, subq_16.metric_time__month) + subq_11.metric_time__month > DATEADD(month, -3, subq_12.metric_time__month) ) -WHERE subq_16.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' +WHERE subq_12.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - subq_16.metric_time__month + subq_12.metric_time__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 264cc81a6d..e9ce4da568 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -1,148 +1,148 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month - , subq_10.txn_revenue AS revenue_all_time + subq_8.metric_time__month + , subq_8.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__month - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_7.metric_time__month + , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_8.metric_time__month - , subq_8.txn_revenue + subq_6.metric_time__month + , subq_6.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] SELECT - subq_7.metric_time__month - , subq_7.txn_revenue + subq_5.metric_time__month + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__month AS metric_time__month - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_4.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_4.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_4.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_4.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_4.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_4.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_4.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_4.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_4.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_4.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.user AS user - , subq_4.revenue_instance__user AS revenue_instance__user - , subq_4.txn_revenue AS txn_revenue + subq_3.metric_time__month AS metric_time__month + , 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.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_2.metric_time__day AS metric_time__day + , subq_2.metric_time__week AS metric_time__week + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.metric_time__extract_day AS metric_time__extract_day + , subq_2.metric_time__extract_dow AS metric_time__extract_dow + , subq_2.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.user AS user + , subq_2.revenue_instance__user AS revenue_instance__user + , subq_2.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_6.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-01-01' AND '2020-01-01' + DATE_TRUNC('month', subq_4.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - DATE_TRUNC('month', subq_6.ds) - ) subq_5 + DATE_TRUNC('month', subq_4.ds) + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] 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.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__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.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue + 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.revenue_instance__ds__day + , subq_1.revenue_instance__ds__week + , subq_1.revenue_instance__ds__month + , subq_1.revenue_instance__ds__quarter + , subq_1.revenue_instance__ds__year + , subq_1.revenue_instance__ds__extract_year + , subq_1.revenue_instance__ds__extract_quarter + , subq_1.revenue_instance__ds__extract_month + , subq_1.revenue_instance__ds__extract_day + , subq_1.revenue_instance__ds__extract_dow + , subq_1.revenue_instance__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.revenue_instance__user + , subq_1.txn_revenue 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.revenue_instance__ds__day - , subq_2.revenue_instance__ds__week - , subq_2.revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__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.user - , subq_2.revenue_instance__user - , subq_2.txn_revenue + 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.revenue_instance__ds__day + , subq_0.revenue_instance__ds__week + , subq_0.revenue_instance__ds__month + , subq_0.revenue_instance__ds__quarter + , subq_0.revenue_instance__ds__year + , subq_0.revenue_instance__ds__extract_year + , subq_0.revenue_instance__ds__extract_quarter + , subq_0.revenue_instance__ds__extract_month + , subq_0.revenue_instance__ds__extract_day + , subq_0.revenue_instance__ds__extract_dow + , subq_0.revenue_instance__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.revenue_instance__user + , subq_0.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -172,16 +172,16 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' + ) subq_2 ON - (subq_4.metric_time__month <= subq_5.metric_time__month) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_9 + (subq_2.metric_time__month <= subq_3.metric_time__month) + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_7 GROUP BY - subq_9.metric_time__month -) subq_10 + subq_7.metric_time__month +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 30ac0eed55..02e630aa1e 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__month AS metric_time__month - , SUM(subq_15.txn_revenue) AS revenue_all_time + subq_12.metric_time__month AS metric_time__month + , SUM(subq_11.txn_revenue) AS revenue_all_time FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', ds) -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -24,9 +24,9 @@ INNER JOIN ( , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' -) subq_15 +) subq_11 ON - (subq_15.metric_time__month <= subq_16.metric_time__month) -WHERE subq_16.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + (subq_11.metric_time__month <= subq_12.metric_time__month) +WHERE subq_12.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_16.metric_time__month + subq_12.metric_time__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql index 836af0ace9..83bca27502 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql @@ -1,146 +1,146 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.txn_revenue AS trailing_2_months_revenue + subq_8.metric_time__day + , subq_8.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_7.metric_time__day + , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_8.metric_time__day - , subq_8.txn_revenue + subq_6.metric_time__day + , subq_6.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.txn_revenue + subq_5.metric_time__day + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_4.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_4.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_4.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_4.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_4.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_4.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_4.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_4.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_4.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_4.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.user AS user - , subq_4.revenue_instance__user AS revenue_instance__user - , subq_4.txn_revenue AS txn_revenue + subq_3.metric_time__day AS metric_time__day + , 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.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_2.metric_time__week AS metric_time__week + , subq_2.metric_time__month AS metric_time__month + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.metric_time__extract_day AS metric_time__extract_day + , subq_2.metric_time__extract_dow AS metric_time__extract_dow + , subq_2.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.user AS user + , subq_2.revenue_instance__user AS revenue_instance__user + , subq_2.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_5 + subq_4.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] 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.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__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.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue + 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.revenue_instance__ds__day + , subq_1.revenue_instance__ds__week + , subq_1.revenue_instance__ds__month + , subq_1.revenue_instance__ds__quarter + , subq_1.revenue_instance__ds__year + , subq_1.revenue_instance__ds__extract_year + , subq_1.revenue_instance__ds__extract_quarter + , subq_1.revenue_instance__ds__extract_month + , subq_1.revenue_instance__ds__extract_day + , subq_1.revenue_instance__ds__extract_dow + , subq_1.revenue_instance__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.revenue_instance__user + , subq_1.txn_revenue 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.revenue_instance__ds__day - , subq_2.revenue_instance__ds__week - , subq_2.revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__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.user - , subq_2.revenue_instance__user - , subq_2.txn_revenue + 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.revenue_instance__ds__day + , subq_0.revenue_instance__ds__week + , subq_0.revenue_instance__ds__month + , subq_0.revenue_instance__ds__quarter + , subq_0.revenue_instance__ds__year + , subq_0.revenue_instance__ds__extract_year + , subq_0.revenue_instance__ds__extract_quarter + , subq_0.revenue_instance__ds__extract_month + , subq_0.revenue_instance__ds__extract_day + , subq_0.revenue_instance__ds__extract_dow + , subq_0.revenue_instance__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.revenue_instance__user + , subq_0.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -170,20 +170,20 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' + ) subq_2 ON ( - subq_4.metric_time__day <= subq_5.metric_time__day + subq_2.metric_time__day <= subq_3.metric_time__day ) AND ( - subq_4.metric_time__day > DATEADD(month, -2, subq_5.metric_time__day) + subq_2.metric_time__day > DATEADD(month, -2, subq_3.metric_time__day) ) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_9 + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_7 GROUP BY - subq_9.metric_time__day -) subq_10 + subq_7.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index cc5537b0c9..cd4811e1ab 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -4,15 +4,15 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , SUM(subq_15.txn_revenue) AS trailing_2_months_revenue + subq_12.metric_time__day AS metric_time__day + , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -22,13 +22,13 @@ INNER JOIN ( , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' -) subq_15 +) subq_11 ON ( - subq_15.metric_time__day <= subq_16.metric_time__day + subq_11.metric_time__day <= subq_12.metric_time__day ) AND ( - subq_15.metric_time__day > DATEADD(month, -2, subq_16.metric_time__day) + subq_11.metric_time__day > DATEADD(month, -2, subq_12.metric_time__day) ) -WHERE subq_16.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' +WHERE subq_12.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_16.metric_time__day + subq_12.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_month__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_month__plan0.sql index 7b5a52155e..5bc9116fc1 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_month__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_month__plan0.sql @@ -1,103 +1,103 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month - , subq_10.bookings_monthly AS trailing_3_months_bookings + subq_8.metric_time__month + , subq_8.bookings_monthly AS trailing_3_months_bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__month - , SUM(subq_9.bookings_monthly) AS bookings_monthly + subq_7.metric_time__month + , SUM(subq_7.bookings_monthly) AS bookings_monthly FROM ( -- Constrain Time Range to [2020-03-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_8.metric_time__month - , subq_8.bookings_monthly + subq_6.metric_time__month + , subq_6.bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_7.metric_time__month - , subq_7.bookings_monthly + subq_5.metric_time__month + , subq_5.bookings_monthly FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__month AS metric_time__month - , subq_4.monthly_ds__month AS monthly_ds__month - , subq_4.monthly_ds__quarter AS monthly_ds__quarter - , subq_4.monthly_ds__year AS monthly_ds__year - , subq_4.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_4.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_4.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_4.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_4.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_4.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_4.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_4.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_4.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.listing AS listing - , subq_4.booking__listing AS booking__listing - , subq_4.bookings_monthly AS bookings_monthly + subq_3.metric_time__month AS metric_time__month + , subq_2.monthly_ds__month AS monthly_ds__month + , subq_2.monthly_ds__quarter AS monthly_ds__quarter + , subq_2.monthly_ds__year AS monthly_ds__year + , subq_2.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_2.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_2.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_2.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_2.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_2.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_2.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_2.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_2.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.listing AS listing + , subq_2.booking__listing AS booking__listing + , subq_2.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_6.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-03-05' AND '2021-01-04' + DATE_TRUNC('month', subq_4.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - DATE_TRUNC('month', subq_6.ds) - ) subq_5 + DATE_TRUNC('month', subq_4.ds) + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-12-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_3.monthly_ds__month - , subq_3.monthly_ds__quarter - , subq_3.monthly_ds__year - , subq_3.monthly_ds__extract_year - , subq_3.monthly_ds__extract_quarter - , subq_3.monthly_ds__extract_month - , subq_3.booking__monthly_ds__month - , subq_3.booking__monthly_ds__quarter - , subq_3.booking__monthly_ds__year - , subq_3.booking__monthly_ds__extract_year - , subq_3.booking__monthly_ds__extract_quarter - , subq_3.booking__monthly_ds__extract_month - , 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.listing - , subq_3.booking__listing - , subq_3.bookings_monthly + subq_1.monthly_ds__month + , subq_1.monthly_ds__quarter + , subq_1.monthly_ds__year + , subq_1.monthly_ds__extract_year + , subq_1.monthly_ds__extract_quarter + , subq_1.monthly_ds__extract_month + , subq_1.booking__monthly_ds__month + , subq_1.booking__monthly_ds__quarter + , subq_1.booking__monthly_ds__year + , subq_1.booking__monthly_ds__extract_year + , subq_1.booking__monthly_ds__extract_quarter + , subq_1.booking__monthly_ds__extract_month + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.listing + , subq_1.booking__listing + , subq_1.bookings_monthly FROM ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_2.monthly_ds__month - , subq_2.monthly_ds__quarter - , subq_2.monthly_ds__year - , subq_2.monthly_ds__extract_year - , subq_2.monthly_ds__extract_quarter - , subq_2.monthly_ds__extract_month - , subq_2.booking__monthly_ds__month - , subq_2.booking__monthly_ds__quarter - , subq_2.booking__monthly_ds__year - , subq_2.booking__monthly_ds__extract_year - , subq_2.booking__monthly_ds__extract_quarter - , subq_2.booking__monthly_ds__extract_month - , subq_2.monthly_ds__month AS metric_time__month - , subq_2.monthly_ds__quarter AS metric_time__quarter - , subq_2.monthly_ds__year AS metric_time__year - , subq_2.monthly_ds__extract_year AS metric_time__extract_year - , subq_2.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_2.monthly_ds__extract_month AS metric_time__extract_month - , subq_2.listing - , subq_2.booking__listing - , subq_2.bookings_monthly + subq_0.monthly_ds__month + , subq_0.monthly_ds__quarter + , subq_0.monthly_ds__year + , subq_0.monthly_ds__extract_year + , subq_0.monthly_ds__extract_quarter + , subq_0.monthly_ds__extract_month + , subq_0.booking__monthly_ds__month + , subq_0.booking__monthly_ds__quarter + , subq_0.booking__monthly_ds__year + , subq_0.booking__monthly_ds__extract_year + , subq_0.booking__monthly_ds__extract_quarter + , subq_0.booking__monthly_ds__extract_month + , subq_0.monthly_ds__month AS metric_time__month + , subq_0.monthly_ds__quarter AS metric_time__quarter + , subq_0.monthly_ds__year AS metric_time__year + , subq_0.monthly_ds__extract_year AS metric_time__extract_year + , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.monthly_ds__extract_month AS metric_time__extract_month + , subq_0.listing + , subq_0.booking__listing + , subq_0.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -117,20 +117,20 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__month BETWEEN '2019-12-05' AND '2021-01-04' + ) subq_2 ON ( - subq_4.metric_time__month <= subq_5.metric_time__month + subq_2.metric_time__month <= subq_3.metric_time__month ) AND ( - subq_4.metric_time__month > DATEADD(month, -3, subq_5.metric_time__month) + subq_2.metric_time__month > DATEADD(month, -3, subq_3.metric_time__month) ) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' - ) subq_9 + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' + ) subq_7 GROUP BY - subq_9.metric_time__month -) subq_10 + subq_7.metric_time__month +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_month__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_month__plan0_optimized.sql index c9b1da3166..4611f8316c 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_month__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_month__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__month AS metric_time__month - , SUM(subq_15.bookings_monthly) AS trailing_3_months_bookings + subq_12.metric_time__month AS metric_time__month + , SUM(subq_11.bookings_monthly) AS trailing_3_months_bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY DATE_TRUNC('month', ds) -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_monthly_source' -- Metric Time Dimension 'monthly_ds' @@ -24,13 +24,13 @@ INNER JOIN ( , bookings_monthly FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 WHERE DATE_TRUNC('month', ds) BETWEEN '2019-12-05' AND '2021-01-04' -) subq_15 +) subq_11 ON ( - subq_15.metric_time__month <= subq_16.metric_time__month + subq_11.metric_time__month <= subq_12.metric_time__month ) AND ( - subq_15.metric_time__month > DATEADD(month, -3, subq_16.metric_time__month) + subq_11.metric_time__month > DATEADD(month, -3, subq_12.metric_time__month) ) -WHERE subq_16.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' +WHERE subq_12.metric_time__month BETWEEN '2020-03-05' AND '2021-01-04' GROUP BY - subq_16.metric_time__month + subq_12.metric_time__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 16615a2d4b..fdc1c54d6b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -1,148 +1,148 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month - , subq_10.txn_revenue AS revenue_all_time + subq_8.metric_time__month + , subq_8.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__month - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_7.metric_time__month + , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_8.metric_time__month - , subq_8.txn_revenue + subq_6.metric_time__month + , subq_6.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] SELECT - subq_7.metric_time__month - , subq_7.txn_revenue + subq_5.metric_time__month + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__month AS metric_time__month - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_4.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_4.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_4.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_4.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_4.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_4.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_4.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_4.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_4.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_4.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.user AS user - , subq_4.revenue_instance__user AS revenue_instance__user - , subq_4.txn_revenue AS txn_revenue + subq_3.metric_time__month AS metric_time__month + , 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.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_2.metric_time__day AS metric_time__day + , subq_2.metric_time__week AS metric_time__week + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.metric_time__extract_day AS metric_time__extract_day + , subq_2.metric_time__extract_dow AS metric_time__extract_dow + , subq_2.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.user AS user + , subq_2.revenue_instance__user AS revenue_instance__user + , subq_2.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_6.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-01-01' AND '2020-01-01' + DATE_TRUNC('month', subq_4.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - DATE_TRUNC('month', subq_6.ds) - ) subq_5 + DATE_TRUNC('month', subq_4.ds) + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] 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.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__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.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue + 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.revenue_instance__ds__day + , subq_1.revenue_instance__ds__week + , subq_1.revenue_instance__ds__month + , subq_1.revenue_instance__ds__quarter + , subq_1.revenue_instance__ds__year + , subq_1.revenue_instance__ds__extract_year + , subq_1.revenue_instance__ds__extract_quarter + , subq_1.revenue_instance__ds__extract_month + , subq_1.revenue_instance__ds__extract_day + , subq_1.revenue_instance__ds__extract_dow + , subq_1.revenue_instance__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.revenue_instance__user + , subq_1.txn_revenue 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.revenue_instance__ds__day - , subq_2.revenue_instance__ds__week - , subq_2.revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__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.user - , subq_2.revenue_instance__user - , subq_2.txn_revenue + 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.revenue_instance__ds__day + , subq_0.revenue_instance__ds__week + , subq_0.revenue_instance__ds__month + , subq_0.revenue_instance__ds__quarter + , subq_0.revenue_instance__ds__year + , subq_0.revenue_instance__ds__extract_year + , subq_0.revenue_instance__ds__extract_quarter + , subq_0.revenue_instance__ds__extract_month + , subq_0.revenue_instance__ds__extract_day + , subq_0.revenue_instance__ds__extract_dow + , subq_0.revenue_instance__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.revenue_instance__user + , subq_0.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -172,16 +172,16 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2000-01-01' AND '2020-01-01' + ) subq_2 ON - (subq_4.metric_time__month <= subq_5.metric_time__month) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_9 + (subq_2.metric_time__month <= subq_3.metric_time__month) + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_7 GROUP BY - subq_9.metric_time__month -) subq_10 + subq_7.metric_time__month +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 30ac0eed55..02e630aa1e 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__month AS metric_time__month - , SUM(subq_15.txn_revenue) AS revenue_all_time + subq_12.metric_time__month AS metric_time__month + , SUM(subq_11.txn_revenue) AS revenue_all_time FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', ds) -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -24,9 +24,9 @@ INNER JOIN ( , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' -) subq_15 +) subq_11 ON - (subq_15.metric_time__month <= subq_16.metric_time__month) -WHERE subq_16.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + (subq_11.metric_time__month <= subq_12.metric_time__month) +WHERE subq_12.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_16.metric_time__month + subq_12.metric_time__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql index f0f5a0da02..1a6cd4c601 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql @@ -1,146 +1,146 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.txn_revenue AS trailing_2_months_revenue + subq_8.metric_time__day + , subq_8.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_7.metric_time__day + , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_8.metric_time__day - , subq_8.txn_revenue + subq_6.metric_time__day + , subq_6.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.txn_revenue + subq_5.metric_time__day + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_4.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_4.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_4.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_4.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_4.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_4.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_4.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_4.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_4.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_4.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.user AS user - , subq_4.revenue_instance__user AS revenue_instance__user - , subq_4.txn_revenue AS txn_revenue + subq_3.metric_time__day AS metric_time__day + , 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.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_2.metric_time__week AS metric_time__week + , subq_2.metric_time__month AS metric_time__month + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.metric_time__extract_day AS metric_time__extract_day + , subq_2.metric_time__extract_dow AS metric_time__extract_dow + , subq_2.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.user AS user + , subq_2.revenue_instance__user AS revenue_instance__user + , subq_2.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_5 + subq_4.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] 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.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__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.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue + 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.revenue_instance__ds__day + , subq_1.revenue_instance__ds__week + , subq_1.revenue_instance__ds__month + , subq_1.revenue_instance__ds__quarter + , subq_1.revenue_instance__ds__year + , subq_1.revenue_instance__ds__extract_year + , subq_1.revenue_instance__ds__extract_quarter + , subq_1.revenue_instance__ds__extract_month + , subq_1.revenue_instance__ds__extract_day + , subq_1.revenue_instance__ds__extract_dow + , subq_1.revenue_instance__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.revenue_instance__user + , subq_1.txn_revenue 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.revenue_instance__ds__day - , subq_2.revenue_instance__ds__week - , subq_2.revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__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.user - , subq_2.revenue_instance__user - , subq_2.txn_revenue + 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.revenue_instance__ds__day + , subq_0.revenue_instance__ds__week + , subq_0.revenue_instance__ds__month + , subq_0.revenue_instance__ds__quarter + , subq_0.revenue_instance__ds__year + , subq_0.revenue_instance__ds__extract_year + , subq_0.revenue_instance__ds__extract_quarter + , subq_0.revenue_instance__ds__extract_month + , subq_0.revenue_instance__ds__extract_day + , subq_0.revenue_instance__ds__extract_dow + , subq_0.revenue_instance__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.revenue_instance__user + , subq_0.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -170,20 +170,20 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' + ) subq_2 ON ( - subq_4.metric_time__day <= subq_5.metric_time__day + subq_2.metric_time__day <= subq_3.metric_time__day ) AND ( - subq_4.metric_time__day > DATEADD(month, -2, subq_5.metric_time__day) + subq_2.metric_time__day > DATEADD(month, -2, subq_3.metric_time__day) ) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_9 + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_7 GROUP BY - subq_9.metric_time__day -) subq_10 + subq_7.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index cc5537b0c9..cd4811e1ab 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -4,15 +4,15 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , SUM(subq_15.txn_revenue) AS trailing_2_months_revenue + subq_12.metric_time__day AS metric_time__day + , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -22,13 +22,13 @@ INNER JOIN ( , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' -) subq_15 +) subq_11 ON ( - subq_15.metric_time__day <= subq_16.metric_time__day + subq_11.metric_time__day <= subq_12.metric_time__day ) AND ( - subq_15.metric_time__day > DATEADD(month, -2, subq_16.metric_time__day) + subq_11.metric_time__day > DATEADD(month, -2, subq_12.metric_time__day) ) -WHERE subq_16.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' +WHERE subq_12.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_16.metric_time__day + subq_12.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_month__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_month__plan0.sql index 03434a57ad..8423ed8494 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_month__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_month__plan0.sql @@ -1,103 +1,103 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month - , subq_10.bookings_monthly AS trailing_3_months_bookings + subq_8.metric_time__month + , subq_8.bookings_monthly AS trailing_3_months_bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__month - , SUM(subq_9.bookings_monthly) AS bookings_monthly + subq_7.metric_time__month + , SUM(subq_7.bookings_monthly) AS bookings_monthly FROM ( -- Constrain Time Range to [2020-03-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_8.metric_time__month - , subq_8.bookings_monthly + subq_6.metric_time__month + , subq_6.bookings_monthly FROM ( -- Pass Only Elements: ['bookings_monthly', 'metric_time__month'] SELECT - subq_7.metric_time__month - , subq_7.bookings_monthly + subq_5.metric_time__month + , subq_5.bookings_monthly FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__month AS metric_time__month - , subq_4.monthly_ds__month AS monthly_ds__month - , subq_4.monthly_ds__quarter AS monthly_ds__quarter - , subq_4.monthly_ds__year AS monthly_ds__year - , subq_4.monthly_ds__extract_year AS monthly_ds__extract_year - , subq_4.monthly_ds__extract_quarter AS monthly_ds__extract_quarter - , subq_4.monthly_ds__extract_month AS monthly_ds__extract_month - , subq_4.booking__monthly_ds__month AS booking__monthly_ds__month - , subq_4.booking__monthly_ds__quarter AS booking__monthly_ds__quarter - , subq_4.booking__monthly_ds__year AS booking__monthly_ds__year - , subq_4.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year - , subq_4.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter - , subq_4.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.listing AS listing - , subq_4.booking__listing AS booking__listing - , subq_4.bookings_monthly AS bookings_monthly + subq_3.metric_time__month AS metric_time__month + , subq_2.monthly_ds__month AS monthly_ds__month + , subq_2.monthly_ds__quarter AS monthly_ds__quarter + , subq_2.monthly_ds__year AS monthly_ds__year + , subq_2.monthly_ds__extract_year AS monthly_ds__extract_year + , subq_2.monthly_ds__extract_quarter AS monthly_ds__extract_quarter + , subq_2.monthly_ds__extract_month AS monthly_ds__extract_month + , subq_2.booking__monthly_ds__month AS booking__monthly_ds__month + , subq_2.booking__monthly_ds__quarter AS booking__monthly_ds__quarter + , subq_2.booking__monthly_ds__year AS booking__monthly_ds__year + , subq_2.booking__monthly_ds__extract_year AS booking__monthly_ds__extract_year + , subq_2.booking__monthly_ds__extract_quarter AS booking__monthly_ds__extract_quarter + , subq_2.booking__monthly_ds__extract_month AS booking__monthly_ds__extract_month + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.listing AS listing + , subq_2.booking__listing AS booking__listing + , subq_2.bookings_monthly AS bookings_monthly FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_6.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN timestamp '2020-03-05' AND timestamp '2021-01-04' + DATE_TRUNC('month', subq_4.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN timestamp '2020-03-05' AND timestamp '2021-01-04' GROUP BY - DATE_TRUNC('month', subq_6.ds) - ) subq_5 + DATE_TRUNC('month', subq_4.ds) + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-12-05T00:00:00, 2021-01-04T00:00:00] SELECT - subq_3.monthly_ds__month - , subq_3.monthly_ds__quarter - , subq_3.monthly_ds__year - , subq_3.monthly_ds__extract_year - , subq_3.monthly_ds__extract_quarter - , subq_3.monthly_ds__extract_month - , subq_3.booking__monthly_ds__month - , subq_3.booking__monthly_ds__quarter - , subq_3.booking__monthly_ds__year - , subq_3.booking__monthly_ds__extract_year - , subq_3.booking__monthly_ds__extract_quarter - , subq_3.booking__monthly_ds__extract_month - , 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.listing - , subq_3.booking__listing - , subq_3.bookings_monthly + subq_1.monthly_ds__month + , subq_1.monthly_ds__quarter + , subq_1.monthly_ds__year + , subq_1.monthly_ds__extract_year + , subq_1.monthly_ds__extract_quarter + , subq_1.monthly_ds__extract_month + , subq_1.booking__monthly_ds__month + , subq_1.booking__monthly_ds__quarter + , subq_1.booking__monthly_ds__year + , subq_1.booking__monthly_ds__extract_year + , subq_1.booking__monthly_ds__extract_quarter + , subq_1.booking__monthly_ds__extract_month + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.listing + , subq_1.booking__listing + , subq_1.bookings_monthly FROM ( -- Metric Time Dimension 'monthly_ds' SELECT - subq_2.monthly_ds__month - , subq_2.monthly_ds__quarter - , subq_2.monthly_ds__year - , subq_2.monthly_ds__extract_year - , subq_2.monthly_ds__extract_quarter - , subq_2.monthly_ds__extract_month - , subq_2.booking__monthly_ds__month - , subq_2.booking__monthly_ds__quarter - , subq_2.booking__monthly_ds__year - , subq_2.booking__monthly_ds__extract_year - , subq_2.booking__monthly_ds__extract_quarter - , subq_2.booking__monthly_ds__extract_month - , subq_2.monthly_ds__month AS metric_time__month - , subq_2.monthly_ds__quarter AS metric_time__quarter - , subq_2.monthly_ds__year AS metric_time__year - , subq_2.monthly_ds__extract_year AS metric_time__extract_year - , subq_2.monthly_ds__extract_quarter AS metric_time__extract_quarter - , subq_2.monthly_ds__extract_month AS metric_time__extract_month - , subq_2.listing - , subq_2.booking__listing - , subq_2.bookings_monthly + subq_0.monthly_ds__month + , subq_0.monthly_ds__quarter + , subq_0.monthly_ds__year + , subq_0.monthly_ds__extract_year + , subq_0.monthly_ds__extract_quarter + , subq_0.monthly_ds__extract_month + , subq_0.booking__monthly_ds__month + , subq_0.booking__monthly_ds__quarter + , subq_0.booking__monthly_ds__year + , subq_0.booking__monthly_ds__extract_year + , subq_0.booking__monthly_ds__extract_quarter + , subq_0.booking__monthly_ds__extract_month + , subq_0.monthly_ds__month AS metric_time__month + , subq_0.monthly_ds__quarter AS metric_time__quarter + , subq_0.monthly_ds__year AS metric_time__year + , subq_0.monthly_ds__extract_year AS metric_time__extract_year + , subq_0.monthly_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.monthly_ds__extract_month AS metric_time__extract_month + , subq_0.listing + , subq_0.booking__listing + , subq_0.bookings_monthly FROM ( -- Read Elements From Semantic Model 'bookings_monthly_source' SELECT @@ -117,20 +117,20 @@ FROM ( , bookings_monthly_source_src_16000.listing_id AS listing , bookings_monthly_source_src_16000.listing_id AS booking__listing FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__month BETWEEN timestamp '2019-12-05' AND timestamp '2021-01-04' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__month BETWEEN timestamp '2019-12-05' AND timestamp '2021-01-04' + ) subq_2 ON ( - subq_4.metric_time__month <= subq_5.metric_time__month + subq_2.metric_time__month <= subq_3.metric_time__month ) AND ( - subq_4.metric_time__month > DATE_ADD('month', -3, subq_5.metric_time__month) + subq_2.metric_time__month > DATE_ADD('month', -3, subq_3.metric_time__month) ) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__month BETWEEN timestamp '2020-03-05' AND timestamp '2021-01-04' - ) subq_9 + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__month BETWEEN timestamp '2020-03-05' AND timestamp '2021-01-04' + ) subq_7 GROUP BY - subq_9.metric_time__month -) subq_10 + subq_7.metric_time__month +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_month__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_month__plan0_optimized.sql index aace0fbfd7..edd17f3f71 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_month__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_month__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__month AS metric_time__month - , SUM(subq_15.bookings_monthly) AS trailing_3_months_bookings + subq_12.metric_time__month AS metric_time__month + , SUM(subq_11.bookings_monthly) AS trailing_3_months_bookings FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN timestamp '2020-03-05' AND timestamp '2021-01-04' GROUP BY DATE_TRUNC('month', ds) -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_monthly_source' -- Metric Time Dimension 'monthly_ds' @@ -24,13 +24,13 @@ INNER JOIN ( , bookings_monthly FROM ***************************.fct_bookings_extended_monthly bookings_monthly_source_src_16000 WHERE DATE_TRUNC('month', ds) BETWEEN timestamp '2019-12-05' AND timestamp '2021-01-04' -) subq_15 +) subq_11 ON ( - subq_15.metric_time__month <= subq_16.metric_time__month + subq_11.metric_time__month <= subq_12.metric_time__month ) AND ( - subq_15.metric_time__month > DATE_ADD('month', -3, subq_16.metric_time__month) + subq_11.metric_time__month > DATE_ADD('month', -3, subq_12.metric_time__month) ) -WHERE subq_16.metric_time__month BETWEEN timestamp '2020-03-05' AND timestamp '2021-01-04' +WHERE subq_12.metric_time__month BETWEEN timestamp '2020-03-05' AND timestamp '2021-01-04' GROUP BY - subq_16.metric_time__month + subq_12.metric_time__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 82552fca16..17b466e217 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -1,148 +1,148 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__month - , subq_10.txn_revenue AS revenue_all_time + subq_8.metric_time__month + , subq_8.txn_revenue AS revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__month - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_7.metric_time__month + , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_8.metric_time__month - , subq_8.txn_revenue + subq_6.metric_time__month + , subq_6.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] SELECT - subq_7.metric_time__month - , subq_7.txn_revenue + subq_5.metric_time__month + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__month AS metric_time__month - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_4.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_4.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_4.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_4.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_4.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_4.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_4.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_4.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_4.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_4.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.user AS user - , subq_4.revenue_instance__user AS revenue_instance__user - , subq_4.txn_revenue AS txn_revenue + subq_3.metric_time__month AS metric_time__month + , 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.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_2.metric_time__day AS metric_time__day + , subq_2.metric_time__week AS metric_time__week + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.metric_time__extract_day AS metric_time__extract_day + , subq_2.metric_time__extract_dow AS metric_time__extract_dow + , subq_2.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.user AS user + , subq_2.revenue_instance__user AS revenue_instance__user + , subq_2.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_6.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + DATE_TRUNC('month', subq_4.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' GROUP BY - DATE_TRUNC('month', subq_6.ds) - ) subq_5 + DATE_TRUNC('month', subq_4.ds) + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] 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.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__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.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue + 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.revenue_instance__ds__day + , subq_1.revenue_instance__ds__week + , subq_1.revenue_instance__ds__month + , subq_1.revenue_instance__ds__quarter + , subq_1.revenue_instance__ds__year + , subq_1.revenue_instance__ds__extract_year + , subq_1.revenue_instance__ds__extract_quarter + , subq_1.revenue_instance__ds__extract_month + , subq_1.revenue_instance__ds__extract_day + , subq_1.revenue_instance__ds__extract_dow + , subq_1.revenue_instance__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.revenue_instance__user + , subq_1.txn_revenue 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.revenue_instance__ds__day - , subq_2.revenue_instance__ds__week - , subq_2.revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__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.user - , subq_2.revenue_instance__user - , subq_2.txn_revenue + 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.revenue_instance__ds__day + , subq_0.revenue_instance__ds__week + , subq_0.revenue_instance__ds__month + , subq_0.revenue_instance__ds__quarter + , subq_0.revenue_instance__ds__year + , subq_0.revenue_instance__ds__extract_year + , subq_0.revenue_instance__ds__extract_quarter + , subq_0.revenue_instance__ds__extract_month + , subq_0.revenue_instance__ds__extract_day + , subq_0.revenue_instance__ds__extract_dow + , subq_0.revenue_instance__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.revenue_instance__user + , subq_0.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -172,16 +172,16 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN timestamp '2000-01-01' AND timestamp '2020-01-01' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN timestamp '2000-01-01' AND timestamp '2020-01-01' + ) subq_2 ON - (subq_4.metric_time__month <= subq_5.metric_time__month) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__month BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' - ) subq_9 + (subq_2.metric_time__month <= subq_3.metric_time__month) + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__month BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + ) subq_7 GROUP BY - subq_9.metric_time__month -) subq_10 + subq_7.metric_time__month +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 6aba83cc41..0fe11f64e6 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -4,17 +4,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__month AS metric_time__month - , SUM(subq_15.txn_revenue) AS revenue_all_time + subq_12.metric_time__month AS metric_time__month + , SUM(subq_11.txn_revenue) AS revenue_all_time FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' GROUP BY DATE_TRUNC('month', ds) -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -24,9 +24,9 @@ INNER JOIN ( , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN timestamp '2000-01-01' AND timestamp '2020-01-01' -) subq_15 +) subq_11 ON - (subq_15.metric_time__month <= subq_16.metric_time__month) -WHERE subq_16.metric_time__month BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + (subq_11.metric_time__month <= subq_12.metric_time__month) +WHERE subq_12.metric_time__month BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' GROUP BY - subq_16.metric_time__month + subq_12.metric_time__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql index 32e0f161d2..7ea5b21ac4 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql @@ -1,146 +1,146 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.txn_revenue AS trailing_2_months_revenue + subq_8.metric_time__day + , subq_8.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_7.metric_time__day + , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_8.metric_time__day - , subq_8.txn_revenue + subq_6.metric_time__day + , subq_6.txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.txn_revenue + subq_5.metric_time__day + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day - , subq_4.ds__week AS ds__week - , subq_4.ds__month AS ds__month - , subq_4.ds__quarter AS ds__quarter - , subq_4.ds__year AS ds__year - , subq_4.ds__extract_year AS ds__extract_year - , subq_4.ds__extract_quarter AS ds__extract_quarter - , subq_4.ds__extract_month AS ds__extract_month - , subq_4.ds__extract_day AS ds__extract_day - , subq_4.ds__extract_dow AS ds__extract_dow - , subq_4.ds__extract_doy AS ds__extract_doy - , subq_4.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_4.revenue_instance__ds__week AS revenue_instance__ds__week - , subq_4.revenue_instance__ds__month AS revenue_instance__ds__month - , subq_4.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_4.revenue_instance__ds__year AS revenue_instance__ds__year - , subq_4.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year - , subq_4.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter - , subq_4.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month - , subq_4.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day - , subq_4.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow - , subq_4.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.user AS user - , subq_4.revenue_instance__user AS revenue_instance__user - , subq_4.txn_revenue AS txn_revenue + subq_3.metric_time__day AS metric_time__day + , 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.revenue_instance__ds__day AS revenue_instance__ds__day + , subq_2.revenue_instance__ds__week AS revenue_instance__ds__week + , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year AS revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter AS revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month AS revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day AS revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow AS revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy AS revenue_instance__ds__extract_doy + , subq_2.metric_time__week AS metric_time__week + , subq_2.metric_time__month AS metric_time__month + , subq_2.metric_time__quarter AS metric_time__quarter + , subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__extract_year AS metric_time__extract_year + , subq_2.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_2.metric_time__extract_month AS metric_time__extract_month + , subq_2.metric_time__extract_day AS metric_time__extract_day + , subq_2.metric_time__extract_dow AS metric_time__extract_dow + , subq_2.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.user AS user + , subq_2.revenue_instance__user AS revenue_instance__user + , subq_2.txn_revenue AS txn_revenue FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_6 - WHERE subq_6.ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' - ) subq_5 + subq_4.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_4 + WHERE subq_4.ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] 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.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__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.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue + 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.revenue_instance__ds__day + , subq_1.revenue_instance__ds__week + , subq_1.revenue_instance__ds__month + , subq_1.revenue_instance__ds__quarter + , subq_1.revenue_instance__ds__year + , subq_1.revenue_instance__ds__extract_year + , subq_1.revenue_instance__ds__extract_quarter + , subq_1.revenue_instance__ds__extract_month + , subq_1.revenue_instance__ds__extract_day + , subq_1.revenue_instance__ds__extract_dow + , subq_1.revenue_instance__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.revenue_instance__user + , subq_1.txn_revenue 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.revenue_instance__ds__day - , subq_2.revenue_instance__ds__week - , subq_2.revenue_instance__ds__month - , subq_2.revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year - , subq_2.revenue_instance__ds__extract_year - , subq_2.revenue_instance__ds__extract_quarter - , subq_2.revenue_instance__ds__extract_month - , subq_2.revenue_instance__ds__extract_day - , subq_2.revenue_instance__ds__extract_dow - , subq_2.revenue_instance__ds__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.user - , subq_2.revenue_instance__user - , subq_2.txn_revenue + 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.revenue_instance__ds__day + , subq_0.revenue_instance__ds__week + , subq_0.revenue_instance__ds__month + , subq_0.revenue_instance__ds__quarter + , subq_0.revenue_instance__ds__year + , subq_0.revenue_instance__ds__extract_year + , subq_0.revenue_instance__ds__extract_quarter + , subq_0.revenue_instance__ds__extract_month + , subq_0.revenue_instance__ds__extract_day + , subq_0.revenue_instance__ds__extract_dow + , subq_0.revenue_instance__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.revenue_instance__user + , subq_0.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -170,20 +170,20 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN timestamp '2019-11-01' AND timestamp '2020-01-01' - ) subq_4 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN timestamp '2019-11-01' AND timestamp '2020-01-01' + ) subq_2 ON ( - subq_4.metric_time__day <= subq_5.metric_time__day + subq_2.metric_time__day <= subq_3.metric_time__day ) AND ( - subq_4.metric_time__day > DATE_ADD('month', -2, subq_5.metric_time__day) + subq_2.metric_time__day > DATE_ADD('month', -2, subq_3.metric_time__day) ) - ) subq_7 - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' - ) subq_9 + ) subq_5 + ) subq_6 + WHERE subq_6.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + ) subq_7 GROUP BY - subq_9.metric_time__day -) subq_10 + subq_7.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index ef9a81fa0b..14fdc3b055 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -4,15 +4,15 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , SUM(subq_15.txn_revenue) AS trailing_2_months_revenue + subq_12.metric_time__day AS metric_time__day + , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' -) subq_16 +) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -22,13 +22,13 @@ INNER JOIN ( , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN timestamp '2019-11-01' AND timestamp '2020-01-01' -) subq_15 +) subq_11 ON ( - subq_15.metric_time__day <= subq_16.metric_time__day + subq_11.metric_time__day <= subq_12.metric_time__day ) AND ( - subq_15.metric_time__day > DATE_ADD('month', -2, subq_16.metric_time__day) + subq_11.metric_time__day > DATE_ADD('month', -2, subq_12.metric_time__day) ) -WHERE subq_16.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' +WHERE subq_12.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' GROUP BY - subq_16.metric_time__day + subq_12.metric_time__day diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml index 72dfca3d9f..5862f3c965 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml @@ -2,40 +2,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml index 03d2b9d006..11c8105735 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml @@ -2,40 +2,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml index 03d2b9d006..11c8105735 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml @@ -2,40 +2,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml index 03d2b9d006..11c8105735 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml @@ -2,40 +2,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml index 03d2b9d006..11c8105735 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml @@ -2,40 +2,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_multihop_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_multihop_joined_plan__ep_0.xml index 03d2b9d006..11c8105735 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_multihop_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_multihop_joined_plan__ep_0.xml @@ -2,40 +2,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0.sql index 8d2cef8941..fd94965a33 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0.sql @@ -8,248 +8,248 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_18.average_booking_value) AS average_booking_value - , MAX(subq_31.bookings) AS bookings - , MAX(subq_39.booking_value) AS booking_value + MAX(subq_12.average_booking_value) AS average_booking_value + , MAX(subq_25.bookings) AS bookings + , MAX(subq_33.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_17.average_booking_value + subq_11.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_16.average_booking_value) AS average_booking_value + AVG(subq_10.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_15.average_booking_value + subq_9.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_14.booking__is_instant - , subq_14.listing__is_lux_latest - , subq_14.average_booking_value + subq_8.booking__is_instant + , subq_8.listing__is_lux_latest + , subq_8.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant - , subq_13.listing__is_lux_latest - , subq_13.average_booking_value + subq_7.booking__is_instant + , subq_7.listing__is_lux_latest + , subq_7.average_booking_value FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.listing AS listing + , subq_3.booking__is_instant AS booking__is_instant + , subq_6.is_lux_latest AS listing__is_lux_latest + , subq_3.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_8.listing - , subq_8.booking__is_instant - , subq_8.average_booking_value + subq_2.listing + , subq_2.booking__is_instant + , subq_2.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_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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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_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 @@ -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_6 - ) subq_7 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_11.listing - , subq_11.is_lux_latest + subq_5.listing + , subq_5.is_lux_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_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.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_10 - ) subq_11 - ) subq_12 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_9.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_30.bookings + subq_24.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_29.bookings) AS bookings + SUM(subq_23.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_28.bookings + subq_22.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_27.booking__is_instant - , subq_27.listing__is_lux_latest - , subq_27.bookings + subq_21.booking__is_instant + , subq_21.listing__is_lux_latest + , subq_21.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_26.booking__is_instant - , subq_26.listing__is_lux_latest - , subq_26.bookings + subq_20.booking__is_instant + , subq_20.listing__is_lux_latest + , subq_20.bookings FROM ( -- Join Standard Outputs SELECT - 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 + subq_16.listing AS listing + , subq_16.booking__is_instant AS booking__is_instant + , subq_19.is_lux_latest AS listing__is_lux_latest + , subq_16.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_21.listing - , subq_21.booking__is_instant - , subq_21.bookings + subq_15.listing + , subq_15.booking__is_instant + , subq_15.bookings FROM ( -- Constrain Output with WHERE SELECT - 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 + 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.metric_time__day + , subq_14.metric_time__week + , subq_14.metric_time__month + , subq_14.metric_time__quarter + , subq_14.metric_time__year + , subq_14.metric_time__extract_year + , subq_14.metric_time__extract_quarter + , subq_14.metric_time__extract_month + , subq_14.metric_time__extract_day + , subq_14.metric_time__extract_dow + , subq_14.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 FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.max_booking_value + , subq_13.min_booking_value + , subq_13.bookers + , subq_13.average_booking_value + , subq_13.referred_bookings + , subq_13.median_booking_value + , subq_13.booking_value_p99 + , subq_13.discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 + , subq_13.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_19 - ) subq_20 + ) subq_13 + ) subq_14 WHERE booking__is_instant - ) subq_21 - ) subq_22 + ) subq_15 + ) subq_16 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_24.listing - , subq_24.is_lux_latest + subq_18.listing + , subq_18.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.created_at__day + , subq_17.created_at__week + , subq_17.created_at__month + , subq_17.created_at__quarter + , subq_17.created_at__year + , subq_17.created_at__extract_year + , subq_17.created_at__extract_quarter + , subq_17.created_at__extract_month + , subq_17.created_at__extract_day + , subq_17.created_at__extract_dow + , subq_17.created_at__extract_doy + , subq_17.listing__ds__day + , subq_17.listing__ds__week + , subq_17.listing__ds__month + , subq_17.listing__ds__quarter + , subq_17.listing__ds__year + , subq_17.listing__ds__extract_year + , subq_17.listing__ds__extract_quarter + , subq_17.listing__ds__extract_month + , subq_17.listing__ds__extract_day + , subq_17.listing__ds__extract_dow + , subq_17.listing__ds__extract_doy + , subq_17.listing__created_at__day + , subq_17.listing__created_at__week + , subq_17.listing__created_at__month + , subq_17.listing__created_at__quarter + , subq_17.listing__created_at__year + , subq_17.listing__created_at__extract_year + , subq_17.listing__created_at__extract_quarter + , subq_17.listing__created_at__extract_month + , subq_17.listing__created_at__extract_day + , subq_17.listing__created_at__extract_dow + , subq_17.listing__created_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.user + , subq_17.listing__user + , subq_17.country_latest + , subq_17.is_lux_latest + , subq_17.capacity_latest + , subq_17.listing__country_latest + , subq_17.listing__is_lux_latest + , subq_17.listing__capacity_latest + , subq_17.listings + , subq_17.largest_listing + , subq_17.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_23 - ) subq_24 - ) subq_25 + ) subq_17 + ) subq_18 + ) subq_19 ON - subq_22.listing = subq_25.listing - ) subq_26 - ) subq_27 + subq_16.listing = subq_19.listing + ) subq_20 + ) subq_21 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 + ) subq_22 + ) subq_23 + ) subq_24 + ) subq_25 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_38.booking_value + subq_32.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_37.booking_value) AS booking_value + SUM(subq_31.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_36.booking_value + subq_30.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_35.booking__is_instant - , subq_35.booking_value + subq_29.booking__is_instant + , subq_29.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_34.booking__is_instant - , subq_34.booking_value + subq_28.booking__is_instant + , subq_28.booking_value FROM ( -- Constrain Output with WHERE SELECT - 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 + subq_27.ds__day + , subq_27.ds__week + , subq_27.ds__month + , subq_27.ds__quarter + , subq_27.ds__year + , subq_27.ds__extract_year + , subq_27.ds__extract_quarter + , subq_27.ds__extract_month + , subq_27.ds__extract_day + , subq_27.ds__extract_dow + , subq_27.ds__extract_doy + , subq_27.ds_partitioned__day + , subq_27.ds_partitioned__week + , subq_27.ds_partitioned__month + , subq_27.ds_partitioned__quarter + , subq_27.ds_partitioned__year + , subq_27.ds_partitioned__extract_year + , subq_27.ds_partitioned__extract_quarter + , subq_27.ds_partitioned__extract_month + , subq_27.ds_partitioned__extract_day + , subq_27.ds_partitioned__extract_dow + , subq_27.ds_partitioned__extract_doy + , subq_27.paid_at__day + , subq_27.paid_at__week + , subq_27.paid_at__month + , subq_27.paid_at__quarter + , subq_27.paid_at__year + , subq_27.paid_at__extract_year + , subq_27.paid_at__extract_quarter + , subq_27.paid_at__extract_month + , subq_27.paid_at__extract_day + , subq_27.paid_at__extract_dow + , subq_27.paid_at__extract_doy + , subq_27.booking__ds__day + , subq_27.booking__ds__week + , subq_27.booking__ds__month + , subq_27.booking__ds__quarter + , subq_27.booking__ds__year + , subq_27.booking__ds__extract_year + , subq_27.booking__ds__extract_quarter + , subq_27.booking__ds__extract_month + , subq_27.booking__ds__extract_day + , subq_27.booking__ds__extract_dow + , subq_27.booking__ds__extract_doy + , subq_27.booking__ds_partitioned__day + , subq_27.booking__ds_partitioned__week + , subq_27.booking__ds_partitioned__month + , subq_27.booking__ds_partitioned__quarter + , subq_27.booking__ds_partitioned__year + , subq_27.booking__ds_partitioned__extract_year + , subq_27.booking__ds_partitioned__extract_quarter + , subq_27.booking__ds_partitioned__extract_month + , subq_27.booking__ds_partitioned__extract_day + , subq_27.booking__ds_partitioned__extract_dow + , subq_27.booking__ds_partitioned__extract_doy + , subq_27.booking__paid_at__day + , subq_27.booking__paid_at__week + , subq_27.booking__paid_at__month + , subq_27.booking__paid_at__quarter + , subq_27.booking__paid_at__year + , subq_27.booking__paid_at__extract_year + , subq_27.booking__paid_at__extract_quarter + , subq_27.booking__paid_at__extract_month + , subq_27.booking__paid_at__extract_day + , subq_27.booking__paid_at__extract_dow + , subq_27.booking__paid_at__extract_doy + , subq_27.metric_time__day + , subq_27.metric_time__week + , subq_27.metric_time__month + , subq_27.metric_time__quarter + , subq_27.metric_time__year + , subq_27.metric_time__extract_year + , subq_27.metric_time__extract_quarter + , subq_27.metric_time__extract_month + , subq_27.metric_time__extract_day + , subq_27.metric_time__extract_dow + , subq_27.metric_time__extract_doy + , subq_27.listing + , subq_27.guest + , subq_27.host + , subq_27.booking__listing + , subq_27.booking__guest + , subq_27.booking__host + , subq_27.is_instant + , subq_27.booking__is_instant + , subq_27.bookings + , subq_27.instant_bookings + , subq_27.booking_value + , subq_27.max_booking_value + , subq_27.min_booking_value + , subq_27.bookers + , subq_27.average_booking_value + , subq_27.referred_bookings + , subq_27.median_booking_value + , subq_27.booking_value_p99 + , subq_27.discrete_booking_value_p99 + , subq_27.approximate_continuous_booking_value_p99 + , subq_27.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_26.ds__day + , subq_26.ds__week + , subq_26.ds__month + , subq_26.ds__quarter + , subq_26.ds__year + , subq_26.ds__extract_year + , subq_26.ds__extract_quarter + , subq_26.ds__extract_month + , subq_26.ds__extract_day + , subq_26.ds__extract_dow + , subq_26.ds__extract_doy + , subq_26.ds_partitioned__day + , subq_26.ds_partitioned__week + , subq_26.ds_partitioned__month + , subq_26.ds_partitioned__quarter + , subq_26.ds_partitioned__year + , subq_26.ds_partitioned__extract_year + , subq_26.ds_partitioned__extract_quarter + , subq_26.ds_partitioned__extract_month + , subq_26.ds_partitioned__extract_day + , subq_26.ds_partitioned__extract_dow + , subq_26.ds_partitioned__extract_doy + , subq_26.paid_at__day + , subq_26.paid_at__week + , subq_26.paid_at__month + , subq_26.paid_at__quarter + , subq_26.paid_at__year + , subq_26.paid_at__extract_year + , subq_26.paid_at__extract_quarter + , subq_26.paid_at__extract_month + , subq_26.paid_at__extract_day + , subq_26.paid_at__extract_dow + , subq_26.paid_at__extract_doy + , subq_26.booking__ds__day + , subq_26.booking__ds__week + , subq_26.booking__ds__month + , subq_26.booking__ds__quarter + , subq_26.booking__ds__year + , subq_26.booking__ds__extract_year + , subq_26.booking__ds__extract_quarter + , subq_26.booking__ds__extract_month + , subq_26.booking__ds__extract_day + , subq_26.booking__ds__extract_dow + , subq_26.booking__ds__extract_doy + , subq_26.booking__ds_partitioned__day + , subq_26.booking__ds_partitioned__week + , subq_26.booking__ds_partitioned__month + , subq_26.booking__ds_partitioned__quarter + , subq_26.booking__ds_partitioned__year + , subq_26.booking__ds_partitioned__extract_year + , subq_26.booking__ds_partitioned__extract_quarter + , subq_26.booking__ds_partitioned__extract_month + , subq_26.booking__ds_partitioned__extract_day + , subq_26.booking__ds_partitioned__extract_dow + , subq_26.booking__ds_partitioned__extract_doy + , subq_26.booking__paid_at__day + , subq_26.booking__paid_at__week + , subq_26.booking__paid_at__month + , subq_26.booking__paid_at__quarter + , subq_26.booking__paid_at__year + , subq_26.booking__paid_at__extract_year + , subq_26.booking__paid_at__extract_quarter + , subq_26.booking__paid_at__extract_month + , subq_26.booking__paid_at__extract_day + , subq_26.booking__paid_at__extract_dow + , subq_26.booking__paid_at__extract_doy + , subq_26.ds__day AS metric_time__day + , subq_26.ds__week AS metric_time__week + , subq_26.ds__month AS metric_time__month + , subq_26.ds__quarter AS metric_time__quarter + , subq_26.ds__year AS metric_time__year + , subq_26.ds__extract_year AS metric_time__extract_year + , subq_26.ds__extract_quarter AS metric_time__extract_quarter + , subq_26.ds__extract_month AS metric_time__extract_month + , subq_26.ds__extract_day AS metric_time__extract_day + , subq_26.ds__extract_dow AS metric_time__extract_dow + , subq_26.ds__extract_doy AS metric_time__extract_doy + , subq_26.listing + , subq_26.guest + , subq_26.host + , subq_26.booking__listing + , subq_26.booking__guest + , subq_26.booking__host + , subq_26.is_instant + , subq_26.booking__is_instant + , subq_26.bookings + , subq_26.instant_bookings + , subq_26.booking_value + , subq_26.max_booking_value + , subq_26.min_booking_value + , subq_26.bookers + , subq_26.average_booking_value + , subq_26.referred_bookings + , subq_26.median_booking_value + , subq_26.booking_value_p99 + , subq_26.discrete_booking_value_p99 + , subq_26.approximate_continuous_booking_value_p99 + , subq_26.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_32 - ) subq_33 + ) subq_26 + ) subq_27 WHERE booking__is_instant - ) subq_34 - ) subq_35 + ) subq_28 + ) subq_29 WHERE booking__is_instant - ) subq_36 - ) subq_37 - ) subq_38 - ) subq_39 - ) subq_40 -) subq_41 + ) subq_30 + ) subq_31 + ) subq_32 + ) subq_33 + ) subq_34 +) subq_35 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0_optimized.sql index eab0cc218b..6a8c176c6c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_60.average_booking_value) AS average_booking_value - , MAX(subq_73.bookings) AS bookings - , MAX(subq_81.booking_value) AS booking_value + MAX(subq_48.average_booking_value) AS average_booking_value + , MAX(subq_61.bookings) AS bookings + , MAX(subq_69.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_51.booking__is_instant AS booking__is_instant + subq_39.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_51.average_booking_value AS average_booking_value + , subq_39.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_49 + ) subq_37 WHERE booking__is_instant - ) subq_51 + ) subq_39 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_51.listing = listings_latest_src_28000.listing_id - ) subq_56 + subq_39.listing = listings_latest_src_28000.listing_id + ) subq_44 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_60 + ) subq_48 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_64.booking__is_instant AS booking__is_instant + subq_52.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_64.bookings AS bookings + , subq_52.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_62 + ) subq_50 WHERE booking__is_instant - ) subq_64 + ) subq_52 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_64.listing = listings_latest_src_28000.listing_id - ) subq_69 + subq_52.listing = listings_latest_src_28000.listing_id + ) subq_57 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_73 + ) subq_61 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_75 + ) subq_63 WHERE booking__is_instant - ) subq_77 + ) subq_65 WHERE booking__is_instant - ) subq_81 - ) subq_82 -) subq_83 + ) subq_69 + ) subq_70 +) subq_71 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0.sql index 9654a4d454..07cb0c7099 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0.sql @@ -8,248 +8,248 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_18.average_booking_value) AS average_booking_value - , MAX(subq_31.bookings) AS bookings - , MAX(subq_39.booking_value) AS booking_value + MAX(subq_12.average_booking_value) AS average_booking_value + , MAX(subq_25.bookings) AS bookings + , MAX(subq_33.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_17.average_booking_value + subq_11.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_16.average_booking_value) AS average_booking_value + AVG(subq_10.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_15.average_booking_value + subq_9.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_14.booking__is_instant - , subq_14.listing__is_lux_latest - , subq_14.average_booking_value + subq_8.booking__is_instant + , subq_8.listing__is_lux_latest + , subq_8.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant - , subq_13.listing__is_lux_latest - , subq_13.average_booking_value + subq_7.booking__is_instant + , subq_7.listing__is_lux_latest + , subq_7.average_booking_value FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.listing AS listing + , subq_3.booking__is_instant AS booking__is_instant + , subq_6.is_lux_latest AS listing__is_lux_latest + , subq_3.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_8.listing - , subq_8.booking__is_instant - , subq_8.average_booking_value + subq_2.listing + , subq_2.booking__is_instant + , subq_2.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_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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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_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 @@ -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_6 - ) subq_7 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_11.listing - , subq_11.is_lux_latest + subq_5.listing + , subq_5.is_lux_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_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.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_10 - ) subq_11 - ) subq_12 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_9.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_30.bookings + subq_24.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_29.bookings) AS bookings + SUM(subq_23.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_28.bookings + subq_22.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_27.booking__is_instant - , subq_27.listing__is_lux_latest - , subq_27.bookings + subq_21.booking__is_instant + , subq_21.listing__is_lux_latest + , subq_21.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_26.booking__is_instant - , subq_26.listing__is_lux_latest - , subq_26.bookings + subq_20.booking__is_instant + , subq_20.listing__is_lux_latest + , subq_20.bookings FROM ( -- Join Standard Outputs SELECT - 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 + subq_16.listing AS listing + , subq_16.booking__is_instant AS booking__is_instant + , subq_19.is_lux_latest AS listing__is_lux_latest + , subq_16.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_21.listing - , subq_21.booking__is_instant - , subq_21.bookings + subq_15.listing + , subq_15.booking__is_instant + , subq_15.bookings FROM ( -- Constrain Output with WHERE SELECT - 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 + 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.metric_time__day + , subq_14.metric_time__week + , subq_14.metric_time__month + , subq_14.metric_time__quarter + , subq_14.metric_time__year + , subq_14.metric_time__extract_year + , subq_14.metric_time__extract_quarter + , subq_14.metric_time__extract_month + , subq_14.metric_time__extract_day + , subq_14.metric_time__extract_dow + , subq_14.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 FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.max_booking_value + , subq_13.min_booking_value + , subq_13.bookers + , subq_13.average_booking_value + , subq_13.referred_bookings + , subq_13.median_booking_value + , subq_13.booking_value_p99 + , subq_13.discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 + , subq_13.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_19 - ) subq_20 + ) subq_13 + ) subq_14 WHERE booking__is_instant - ) subq_21 - ) subq_22 + ) subq_15 + ) subq_16 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_24.listing - , subq_24.is_lux_latest + subq_18.listing + , subq_18.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.created_at__day + , subq_17.created_at__week + , subq_17.created_at__month + , subq_17.created_at__quarter + , subq_17.created_at__year + , subq_17.created_at__extract_year + , subq_17.created_at__extract_quarter + , subq_17.created_at__extract_month + , subq_17.created_at__extract_day + , subq_17.created_at__extract_dow + , subq_17.created_at__extract_doy + , subq_17.listing__ds__day + , subq_17.listing__ds__week + , subq_17.listing__ds__month + , subq_17.listing__ds__quarter + , subq_17.listing__ds__year + , subq_17.listing__ds__extract_year + , subq_17.listing__ds__extract_quarter + , subq_17.listing__ds__extract_month + , subq_17.listing__ds__extract_day + , subq_17.listing__ds__extract_dow + , subq_17.listing__ds__extract_doy + , subq_17.listing__created_at__day + , subq_17.listing__created_at__week + , subq_17.listing__created_at__month + , subq_17.listing__created_at__quarter + , subq_17.listing__created_at__year + , subq_17.listing__created_at__extract_year + , subq_17.listing__created_at__extract_quarter + , subq_17.listing__created_at__extract_month + , subq_17.listing__created_at__extract_day + , subq_17.listing__created_at__extract_dow + , subq_17.listing__created_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.user + , subq_17.listing__user + , subq_17.country_latest + , subq_17.is_lux_latest + , subq_17.capacity_latest + , subq_17.listing__country_latest + , subq_17.listing__is_lux_latest + , subq_17.listing__capacity_latest + , subq_17.listings + , subq_17.largest_listing + , subq_17.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_23 - ) subq_24 - ) subq_25 + ) subq_17 + ) subq_18 + ) subq_19 ON - subq_22.listing = subq_25.listing - ) subq_26 - ) subq_27 + subq_16.listing = subq_19.listing + ) subq_20 + ) subq_21 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 + ) subq_22 + ) subq_23 + ) subq_24 + ) subq_25 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_38.booking_value + subq_32.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_37.booking_value) AS booking_value + SUM(subq_31.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_36.booking_value + subq_30.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_35.booking__is_instant - , subq_35.booking_value + subq_29.booking__is_instant + , subq_29.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_34.booking__is_instant - , subq_34.booking_value + subq_28.booking__is_instant + , subq_28.booking_value FROM ( -- Constrain Output with WHERE SELECT - 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 + subq_27.ds__day + , subq_27.ds__week + , subq_27.ds__month + , subq_27.ds__quarter + , subq_27.ds__year + , subq_27.ds__extract_year + , subq_27.ds__extract_quarter + , subq_27.ds__extract_month + , subq_27.ds__extract_day + , subq_27.ds__extract_dow + , subq_27.ds__extract_doy + , subq_27.ds_partitioned__day + , subq_27.ds_partitioned__week + , subq_27.ds_partitioned__month + , subq_27.ds_partitioned__quarter + , subq_27.ds_partitioned__year + , subq_27.ds_partitioned__extract_year + , subq_27.ds_partitioned__extract_quarter + , subq_27.ds_partitioned__extract_month + , subq_27.ds_partitioned__extract_day + , subq_27.ds_partitioned__extract_dow + , subq_27.ds_partitioned__extract_doy + , subq_27.paid_at__day + , subq_27.paid_at__week + , subq_27.paid_at__month + , subq_27.paid_at__quarter + , subq_27.paid_at__year + , subq_27.paid_at__extract_year + , subq_27.paid_at__extract_quarter + , subq_27.paid_at__extract_month + , subq_27.paid_at__extract_day + , subq_27.paid_at__extract_dow + , subq_27.paid_at__extract_doy + , subq_27.booking__ds__day + , subq_27.booking__ds__week + , subq_27.booking__ds__month + , subq_27.booking__ds__quarter + , subq_27.booking__ds__year + , subq_27.booking__ds__extract_year + , subq_27.booking__ds__extract_quarter + , subq_27.booking__ds__extract_month + , subq_27.booking__ds__extract_day + , subq_27.booking__ds__extract_dow + , subq_27.booking__ds__extract_doy + , subq_27.booking__ds_partitioned__day + , subq_27.booking__ds_partitioned__week + , subq_27.booking__ds_partitioned__month + , subq_27.booking__ds_partitioned__quarter + , subq_27.booking__ds_partitioned__year + , subq_27.booking__ds_partitioned__extract_year + , subq_27.booking__ds_partitioned__extract_quarter + , subq_27.booking__ds_partitioned__extract_month + , subq_27.booking__ds_partitioned__extract_day + , subq_27.booking__ds_partitioned__extract_dow + , subq_27.booking__ds_partitioned__extract_doy + , subq_27.booking__paid_at__day + , subq_27.booking__paid_at__week + , subq_27.booking__paid_at__month + , subq_27.booking__paid_at__quarter + , subq_27.booking__paid_at__year + , subq_27.booking__paid_at__extract_year + , subq_27.booking__paid_at__extract_quarter + , subq_27.booking__paid_at__extract_month + , subq_27.booking__paid_at__extract_day + , subq_27.booking__paid_at__extract_dow + , subq_27.booking__paid_at__extract_doy + , subq_27.metric_time__day + , subq_27.metric_time__week + , subq_27.metric_time__month + , subq_27.metric_time__quarter + , subq_27.metric_time__year + , subq_27.metric_time__extract_year + , subq_27.metric_time__extract_quarter + , subq_27.metric_time__extract_month + , subq_27.metric_time__extract_day + , subq_27.metric_time__extract_dow + , subq_27.metric_time__extract_doy + , subq_27.listing + , subq_27.guest + , subq_27.host + , subq_27.booking__listing + , subq_27.booking__guest + , subq_27.booking__host + , subq_27.is_instant + , subq_27.booking__is_instant + , subq_27.bookings + , subq_27.instant_bookings + , subq_27.booking_value + , subq_27.max_booking_value + , subq_27.min_booking_value + , subq_27.bookers + , subq_27.average_booking_value + , subq_27.referred_bookings + , subq_27.median_booking_value + , subq_27.booking_value_p99 + , subq_27.discrete_booking_value_p99 + , subq_27.approximate_continuous_booking_value_p99 + , subq_27.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_26.ds__day + , subq_26.ds__week + , subq_26.ds__month + , subq_26.ds__quarter + , subq_26.ds__year + , subq_26.ds__extract_year + , subq_26.ds__extract_quarter + , subq_26.ds__extract_month + , subq_26.ds__extract_day + , subq_26.ds__extract_dow + , subq_26.ds__extract_doy + , subq_26.ds_partitioned__day + , subq_26.ds_partitioned__week + , subq_26.ds_partitioned__month + , subq_26.ds_partitioned__quarter + , subq_26.ds_partitioned__year + , subq_26.ds_partitioned__extract_year + , subq_26.ds_partitioned__extract_quarter + , subq_26.ds_partitioned__extract_month + , subq_26.ds_partitioned__extract_day + , subq_26.ds_partitioned__extract_dow + , subq_26.ds_partitioned__extract_doy + , subq_26.paid_at__day + , subq_26.paid_at__week + , subq_26.paid_at__month + , subq_26.paid_at__quarter + , subq_26.paid_at__year + , subq_26.paid_at__extract_year + , subq_26.paid_at__extract_quarter + , subq_26.paid_at__extract_month + , subq_26.paid_at__extract_day + , subq_26.paid_at__extract_dow + , subq_26.paid_at__extract_doy + , subq_26.booking__ds__day + , subq_26.booking__ds__week + , subq_26.booking__ds__month + , subq_26.booking__ds__quarter + , subq_26.booking__ds__year + , subq_26.booking__ds__extract_year + , subq_26.booking__ds__extract_quarter + , subq_26.booking__ds__extract_month + , subq_26.booking__ds__extract_day + , subq_26.booking__ds__extract_dow + , subq_26.booking__ds__extract_doy + , subq_26.booking__ds_partitioned__day + , subq_26.booking__ds_partitioned__week + , subq_26.booking__ds_partitioned__month + , subq_26.booking__ds_partitioned__quarter + , subq_26.booking__ds_partitioned__year + , subq_26.booking__ds_partitioned__extract_year + , subq_26.booking__ds_partitioned__extract_quarter + , subq_26.booking__ds_partitioned__extract_month + , subq_26.booking__ds_partitioned__extract_day + , subq_26.booking__ds_partitioned__extract_dow + , subq_26.booking__ds_partitioned__extract_doy + , subq_26.booking__paid_at__day + , subq_26.booking__paid_at__week + , subq_26.booking__paid_at__month + , subq_26.booking__paid_at__quarter + , subq_26.booking__paid_at__year + , subq_26.booking__paid_at__extract_year + , subq_26.booking__paid_at__extract_quarter + , subq_26.booking__paid_at__extract_month + , subq_26.booking__paid_at__extract_day + , subq_26.booking__paid_at__extract_dow + , subq_26.booking__paid_at__extract_doy + , subq_26.ds__day AS metric_time__day + , subq_26.ds__week AS metric_time__week + , subq_26.ds__month AS metric_time__month + , subq_26.ds__quarter AS metric_time__quarter + , subq_26.ds__year AS metric_time__year + , subq_26.ds__extract_year AS metric_time__extract_year + , subq_26.ds__extract_quarter AS metric_time__extract_quarter + , subq_26.ds__extract_month AS metric_time__extract_month + , subq_26.ds__extract_day AS metric_time__extract_day + , subq_26.ds__extract_dow AS metric_time__extract_dow + , subq_26.ds__extract_doy AS metric_time__extract_doy + , subq_26.listing + , subq_26.guest + , subq_26.host + , subq_26.booking__listing + , subq_26.booking__guest + , subq_26.booking__host + , subq_26.is_instant + , subq_26.booking__is_instant + , subq_26.bookings + , subq_26.instant_bookings + , subq_26.booking_value + , subq_26.max_booking_value + , subq_26.min_booking_value + , subq_26.bookers + , subq_26.average_booking_value + , subq_26.referred_bookings + , subq_26.median_booking_value + , subq_26.booking_value_p99 + , subq_26.discrete_booking_value_p99 + , subq_26.approximate_continuous_booking_value_p99 + , subq_26.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_32 - ) subq_33 + ) subq_26 + ) subq_27 WHERE booking__is_instant - ) subq_34 - ) subq_35 + ) subq_28 + ) subq_29 WHERE booking__is_instant - ) subq_36 - ) subq_37 - ) subq_38 - ) subq_39 - ) subq_40 -) subq_41 + ) subq_30 + ) subq_31 + ) subq_32 + ) subq_33 + ) subq_34 +) subq_35 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0_optimized.sql index eab0cc218b..6a8c176c6c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_60.average_booking_value) AS average_booking_value - , MAX(subq_73.bookings) AS bookings - , MAX(subq_81.booking_value) AS booking_value + MAX(subq_48.average_booking_value) AS average_booking_value + , MAX(subq_61.bookings) AS bookings + , MAX(subq_69.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_51.booking__is_instant AS booking__is_instant + subq_39.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_51.average_booking_value AS average_booking_value + , subq_39.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_49 + ) subq_37 WHERE booking__is_instant - ) subq_51 + ) subq_39 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_51.listing = listings_latest_src_28000.listing_id - ) subq_56 + subq_39.listing = listings_latest_src_28000.listing_id + ) subq_44 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_60 + ) subq_48 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_64.booking__is_instant AS booking__is_instant + subq_52.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_64.bookings AS bookings + , subq_52.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_62 + ) subq_50 WHERE booking__is_instant - ) subq_64 + ) subq_52 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_64.listing = listings_latest_src_28000.listing_id - ) subq_69 + subq_52.listing = listings_latest_src_28000.listing_id + ) subq_57 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_73 + ) subq_61 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_75 + ) subq_63 WHERE booking__is_instant - ) subq_77 + ) subq_65 WHERE booking__is_instant - ) subq_81 - ) subq_82 -) subq_83 + ) subq_69 + ) subq_70 +) subq_71 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0.sql index c4c3c5c749..222503e6bd 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0.sql @@ -8,248 +8,248 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_18.average_booking_value) AS average_booking_value - , MAX(subq_31.bookings) AS bookings - , MAX(subq_39.booking_value) AS booking_value + MAX(subq_12.average_booking_value) AS average_booking_value + , MAX(subq_25.bookings) AS bookings + , MAX(subq_33.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_17.average_booking_value + subq_11.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_16.average_booking_value) AS average_booking_value + AVG(subq_10.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_15.average_booking_value + subq_9.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_14.booking__is_instant - , subq_14.listing__is_lux_latest - , subq_14.average_booking_value + subq_8.booking__is_instant + , subq_8.listing__is_lux_latest + , subq_8.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant - , subq_13.listing__is_lux_latest - , subq_13.average_booking_value + subq_7.booking__is_instant + , subq_7.listing__is_lux_latest + , subq_7.average_booking_value FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.listing AS listing + , subq_3.booking__is_instant AS booking__is_instant + , subq_6.is_lux_latest AS listing__is_lux_latest + , subq_3.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_8.listing - , subq_8.booking__is_instant - , subq_8.average_booking_value + subq_2.listing + , subq_2.booking__is_instant + , subq_2.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_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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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_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 @@ -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_6 - ) subq_7 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_11.listing - , subq_11.is_lux_latest + subq_5.listing + , subq_5.is_lux_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_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.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_10 - ) subq_11 - ) subq_12 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_9.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_30.bookings + subq_24.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_29.bookings) AS bookings + SUM(subq_23.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_28.bookings + subq_22.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_27.booking__is_instant - , subq_27.listing__is_lux_latest - , subq_27.bookings + subq_21.booking__is_instant + , subq_21.listing__is_lux_latest + , subq_21.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_26.booking__is_instant - , subq_26.listing__is_lux_latest - , subq_26.bookings + subq_20.booking__is_instant + , subq_20.listing__is_lux_latest + , subq_20.bookings FROM ( -- Join Standard Outputs SELECT - 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 + subq_16.listing AS listing + , subq_16.booking__is_instant AS booking__is_instant + , subq_19.is_lux_latest AS listing__is_lux_latest + , subq_16.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_21.listing - , subq_21.booking__is_instant - , subq_21.bookings + subq_15.listing + , subq_15.booking__is_instant + , subq_15.bookings FROM ( -- Constrain Output with WHERE SELECT - 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 + 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.metric_time__day + , subq_14.metric_time__week + , subq_14.metric_time__month + , subq_14.metric_time__quarter + , subq_14.metric_time__year + , subq_14.metric_time__extract_year + , subq_14.metric_time__extract_quarter + , subq_14.metric_time__extract_month + , subq_14.metric_time__extract_day + , subq_14.metric_time__extract_dow + , subq_14.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 FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.max_booking_value + , subq_13.min_booking_value + , subq_13.bookers + , subq_13.average_booking_value + , subq_13.referred_bookings + , subq_13.median_booking_value + , subq_13.booking_value_p99 + , subq_13.discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 + , subq_13.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_19 - ) subq_20 + ) subq_13 + ) subq_14 WHERE booking__is_instant - ) subq_21 - ) subq_22 + ) subq_15 + ) subq_16 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_24.listing - , subq_24.is_lux_latest + subq_18.listing + , subq_18.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.created_at__day + , subq_17.created_at__week + , subq_17.created_at__month + , subq_17.created_at__quarter + , subq_17.created_at__year + , subq_17.created_at__extract_year + , subq_17.created_at__extract_quarter + , subq_17.created_at__extract_month + , subq_17.created_at__extract_day + , subq_17.created_at__extract_dow + , subq_17.created_at__extract_doy + , subq_17.listing__ds__day + , subq_17.listing__ds__week + , subq_17.listing__ds__month + , subq_17.listing__ds__quarter + , subq_17.listing__ds__year + , subq_17.listing__ds__extract_year + , subq_17.listing__ds__extract_quarter + , subq_17.listing__ds__extract_month + , subq_17.listing__ds__extract_day + , subq_17.listing__ds__extract_dow + , subq_17.listing__ds__extract_doy + , subq_17.listing__created_at__day + , subq_17.listing__created_at__week + , subq_17.listing__created_at__month + , subq_17.listing__created_at__quarter + , subq_17.listing__created_at__year + , subq_17.listing__created_at__extract_year + , subq_17.listing__created_at__extract_quarter + , subq_17.listing__created_at__extract_month + , subq_17.listing__created_at__extract_day + , subq_17.listing__created_at__extract_dow + , subq_17.listing__created_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.user + , subq_17.listing__user + , subq_17.country_latest + , subq_17.is_lux_latest + , subq_17.capacity_latest + , subq_17.listing__country_latest + , subq_17.listing__is_lux_latest + , subq_17.listing__capacity_latest + , subq_17.listings + , subq_17.largest_listing + , subq_17.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_23 - ) subq_24 - ) subq_25 + ) subq_17 + ) subq_18 + ) subq_19 ON - subq_22.listing = subq_25.listing - ) subq_26 - ) subq_27 + subq_16.listing = subq_19.listing + ) subq_20 + ) subq_21 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 + ) subq_22 + ) subq_23 + ) subq_24 + ) subq_25 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_38.booking_value + subq_32.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_37.booking_value) AS booking_value + SUM(subq_31.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_36.booking_value + subq_30.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_35.booking__is_instant - , subq_35.booking_value + subq_29.booking__is_instant + , subq_29.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_34.booking__is_instant - , subq_34.booking_value + subq_28.booking__is_instant + , subq_28.booking_value FROM ( -- Constrain Output with WHERE SELECT - 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 + subq_27.ds__day + , subq_27.ds__week + , subq_27.ds__month + , subq_27.ds__quarter + , subq_27.ds__year + , subq_27.ds__extract_year + , subq_27.ds__extract_quarter + , subq_27.ds__extract_month + , subq_27.ds__extract_day + , subq_27.ds__extract_dow + , subq_27.ds__extract_doy + , subq_27.ds_partitioned__day + , subq_27.ds_partitioned__week + , subq_27.ds_partitioned__month + , subq_27.ds_partitioned__quarter + , subq_27.ds_partitioned__year + , subq_27.ds_partitioned__extract_year + , subq_27.ds_partitioned__extract_quarter + , subq_27.ds_partitioned__extract_month + , subq_27.ds_partitioned__extract_day + , subq_27.ds_partitioned__extract_dow + , subq_27.ds_partitioned__extract_doy + , subq_27.paid_at__day + , subq_27.paid_at__week + , subq_27.paid_at__month + , subq_27.paid_at__quarter + , subq_27.paid_at__year + , subq_27.paid_at__extract_year + , subq_27.paid_at__extract_quarter + , subq_27.paid_at__extract_month + , subq_27.paid_at__extract_day + , subq_27.paid_at__extract_dow + , subq_27.paid_at__extract_doy + , subq_27.booking__ds__day + , subq_27.booking__ds__week + , subq_27.booking__ds__month + , subq_27.booking__ds__quarter + , subq_27.booking__ds__year + , subq_27.booking__ds__extract_year + , subq_27.booking__ds__extract_quarter + , subq_27.booking__ds__extract_month + , subq_27.booking__ds__extract_day + , subq_27.booking__ds__extract_dow + , subq_27.booking__ds__extract_doy + , subq_27.booking__ds_partitioned__day + , subq_27.booking__ds_partitioned__week + , subq_27.booking__ds_partitioned__month + , subq_27.booking__ds_partitioned__quarter + , subq_27.booking__ds_partitioned__year + , subq_27.booking__ds_partitioned__extract_year + , subq_27.booking__ds_partitioned__extract_quarter + , subq_27.booking__ds_partitioned__extract_month + , subq_27.booking__ds_partitioned__extract_day + , subq_27.booking__ds_partitioned__extract_dow + , subq_27.booking__ds_partitioned__extract_doy + , subq_27.booking__paid_at__day + , subq_27.booking__paid_at__week + , subq_27.booking__paid_at__month + , subq_27.booking__paid_at__quarter + , subq_27.booking__paid_at__year + , subq_27.booking__paid_at__extract_year + , subq_27.booking__paid_at__extract_quarter + , subq_27.booking__paid_at__extract_month + , subq_27.booking__paid_at__extract_day + , subq_27.booking__paid_at__extract_dow + , subq_27.booking__paid_at__extract_doy + , subq_27.metric_time__day + , subq_27.metric_time__week + , subq_27.metric_time__month + , subq_27.metric_time__quarter + , subq_27.metric_time__year + , subq_27.metric_time__extract_year + , subq_27.metric_time__extract_quarter + , subq_27.metric_time__extract_month + , subq_27.metric_time__extract_day + , subq_27.metric_time__extract_dow + , subq_27.metric_time__extract_doy + , subq_27.listing + , subq_27.guest + , subq_27.host + , subq_27.booking__listing + , subq_27.booking__guest + , subq_27.booking__host + , subq_27.is_instant + , subq_27.booking__is_instant + , subq_27.bookings + , subq_27.instant_bookings + , subq_27.booking_value + , subq_27.max_booking_value + , subq_27.min_booking_value + , subq_27.bookers + , subq_27.average_booking_value + , subq_27.referred_bookings + , subq_27.median_booking_value + , subq_27.booking_value_p99 + , subq_27.discrete_booking_value_p99 + , subq_27.approximate_continuous_booking_value_p99 + , subq_27.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_26.ds__day + , subq_26.ds__week + , subq_26.ds__month + , subq_26.ds__quarter + , subq_26.ds__year + , subq_26.ds__extract_year + , subq_26.ds__extract_quarter + , subq_26.ds__extract_month + , subq_26.ds__extract_day + , subq_26.ds__extract_dow + , subq_26.ds__extract_doy + , subq_26.ds_partitioned__day + , subq_26.ds_partitioned__week + , subq_26.ds_partitioned__month + , subq_26.ds_partitioned__quarter + , subq_26.ds_partitioned__year + , subq_26.ds_partitioned__extract_year + , subq_26.ds_partitioned__extract_quarter + , subq_26.ds_partitioned__extract_month + , subq_26.ds_partitioned__extract_day + , subq_26.ds_partitioned__extract_dow + , subq_26.ds_partitioned__extract_doy + , subq_26.paid_at__day + , subq_26.paid_at__week + , subq_26.paid_at__month + , subq_26.paid_at__quarter + , subq_26.paid_at__year + , subq_26.paid_at__extract_year + , subq_26.paid_at__extract_quarter + , subq_26.paid_at__extract_month + , subq_26.paid_at__extract_day + , subq_26.paid_at__extract_dow + , subq_26.paid_at__extract_doy + , subq_26.booking__ds__day + , subq_26.booking__ds__week + , subq_26.booking__ds__month + , subq_26.booking__ds__quarter + , subq_26.booking__ds__year + , subq_26.booking__ds__extract_year + , subq_26.booking__ds__extract_quarter + , subq_26.booking__ds__extract_month + , subq_26.booking__ds__extract_day + , subq_26.booking__ds__extract_dow + , subq_26.booking__ds__extract_doy + , subq_26.booking__ds_partitioned__day + , subq_26.booking__ds_partitioned__week + , subq_26.booking__ds_partitioned__month + , subq_26.booking__ds_partitioned__quarter + , subq_26.booking__ds_partitioned__year + , subq_26.booking__ds_partitioned__extract_year + , subq_26.booking__ds_partitioned__extract_quarter + , subq_26.booking__ds_partitioned__extract_month + , subq_26.booking__ds_partitioned__extract_day + , subq_26.booking__ds_partitioned__extract_dow + , subq_26.booking__ds_partitioned__extract_doy + , subq_26.booking__paid_at__day + , subq_26.booking__paid_at__week + , subq_26.booking__paid_at__month + , subq_26.booking__paid_at__quarter + , subq_26.booking__paid_at__year + , subq_26.booking__paid_at__extract_year + , subq_26.booking__paid_at__extract_quarter + , subq_26.booking__paid_at__extract_month + , subq_26.booking__paid_at__extract_day + , subq_26.booking__paid_at__extract_dow + , subq_26.booking__paid_at__extract_doy + , subq_26.ds__day AS metric_time__day + , subq_26.ds__week AS metric_time__week + , subq_26.ds__month AS metric_time__month + , subq_26.ds__quarter AS metric_time__quarter + , subq_26.ds__year AS metric_time__year + , subq_26.ds__extract_year AS metric_time__extract_year + , subq_26.ds__extract_quarter AS metric_time__extract_quarter + , subq_26.ds__extract_month AS metric_time__extract_month + , subq_26.ds__extract_day AS metric_time__extract_day + , subq_26.ds__extract_dow AS metric_time__extract_dow + , subq_26.ds__extract_doy AS metric_time__extract_doy + , subq_26.listing + , subq_26.guest + , subq_26.host + , subq_26.booking__listing + , subq_26.booking__guest + , subq_26.booking__host + , subq_26.is_instant + , subq_26.booking__is_instant + , subq_26.bookings + , subq_26.instant_bookings + , subq_26.booking_value + , subq_26.max_booking_value + , subq_26.min_booking_value + , subq_26.bookers + , subq_26.average_booking_value + , subq_26.referred_bookings + , subq_26.median_booking_value + , subq_26.booking_value_p99 + , subq_26.discrete_booking_value_p99 + , subq_26.approximate_continuous_booking_value_p99 + , subq_26.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_32 - ) subq_33 + ) subq_26 + ) subq_27 WHERE booking__is_instant - ) subq_34 - ) subq_35 + ) subq_28 + ) subq_29 WHERE booking__is_instant - ) subq_36 - ) subq_37 - ) subq_38 - ) subq_39 - ) subq_40 -) subq_41 + ) subq_30 + ) subq_31 + ) subq_32 + ) subq_33 + ) subq_34 +) subq_35 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0_optimized.sql index eab0cc218b..6a8c176c6c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_60.average_booking_value) AS average_booking_value - , MAX(subq_73.bookings) AS bookings - , MAX(subq_81.booking_value) AS booking_value + MAX(subq_48.average_booking_value) AS average_booking_value + , MAX(subq_61.bookings) AS bookings + , MAX(subq_69.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_51.booking__is_instant AS booking__is_instant + subq_39.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_51.average_booking_value AS average_booking_value + , subq_39.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_49 + ) subq_37 WHERE booking__is_instant - ) subq_51 + ) subq_39 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_51.listing = listings_latest_src_28000.listing_id - ) subq_56 + subq_39.listing = listings_latest_src_28000.listing_id + ) subq_44 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_60 + ) subq_48 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_64.booking__is_instant AS booking__is_instant + subq_52.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_64.bookings AS bookings + , subq_52.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_62 + ) subq_50 WHERE booking__is_instant - ) subq_64 + ) subq_52 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_64.listing = listings_latest_src_28000.listing_id - ) subq_69 + subq_52.listing = listings_latest_src_28000.listing_id + ) subq_57 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_73 + ) subq_61 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_75 + ) subq_63 WHERE booking__is_instant - ) subq_77 + ) subq_65 WHERE booking__is_instant - ) subq_81 - ) subq_82 -) subq_83 + ) subq_69 + ) subq_70 +) subq_71 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0.sql index c6a4999e10..e89b7e22d2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0.sql @@ -8,248 +8,248 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_18.average_booking_value) AS average_booking_value - , MAX(subq_31.bookings) AS bookings - , MAX(subq_39.booking_value) AS booking_value + MAX(subq_12.average_booking_value) AS average_booking_value + , MAX(subq_25.bookings) AS bookings + , MAX(subq_33.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_17.average_booking_value + subq_11.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_16.average_booking_value) AS average_booking_value + AVG(subq_10.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_15.average_booking_value + subq_9.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_14.booking__is_instant - , subq_14.listing__is_lux_latest - , subq_14.average_booking_value + subq_8.booking__is_instant + , subq_8.listing__is_lux_latest + , subq_8.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant - , subq_13.listing__is_lux_latest - , subq_13.average_booking_value + subq_7.booking__is_instant + , subq_7.listing__is_lux_latest + , subq_7.average_booking_value FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.listing AS listing + , subq_3.booking__is_instant AS booking__is_instant + , subq_6.is_lux_latest AS listing__is_lux_latest + , subq_3.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_8.listing - , subq_8.booking__is_instant - , subq_8.average_booking_value + subq_2.listing + , subq_2.booking__is_instant + , subq_2.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_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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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_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 @@ -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_6 - ) subq_7 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_11.listing - , subq_11.is_lux_latest + subq_5.listing + , subq_5.is_lux_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_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.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_10 - ) subq_11 - ) subq_12 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_9.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_30.bookings + subq_24.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_29.bookings) AS bookings + SUM(subq_23.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_28.bookings + subq_22.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_27.booking__is_instant - , subq_27.listing__is_lux_latest - , subq_27.bookings + subq_21.booking__is_instant + , subq_21.listing__is_lux_latest + , subq_21.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_26.booking__is_instant - , subq_26.listing__is_lux_latest - , subq_26.bookings + subq_20.booking__is_instant + , subq_20.listing__is_lux_latest + , subq_20.bookings FROM ( -- Join Standard Outputs SELECT - 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 + subq_16.listing AS listing + , subq_16.booking__is_instant AS booking__is_instant + , subq_19.is_lux_latest AS listing__is_lux_latest + , subq_16.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_21.listing - , subq_21.booking__is_instant - , subq_21.bookings + subq_15.listing + , subq_15.booking__is_instant + , subq_15.bookings FROM ( -- Constrain Output with WHERE SELECT - 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 + 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.metric_time__day + , subq_14.metric_time__week + , subq_14.metric_time__month + , subq_14.metric_time__quarter + , subq_14.metric_time__year + , subq_14.metric_time__extract_year + , subq_14.metric_time__extract_quarter + , subq_14.metric_time__extract_month + , subq_14.metric_time__extract_day + , subq_14.metric_time__extract_dow + , subq_14.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 FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.max_booking_value + , subq_13.min_booking_value + , subq_13.bookers + , subq_13.average_booking_value + , subq_13.referred_bookings + , subq_13.median_booking_value + , subq_13.booking_value_p99 + , subq_13.discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 + , subq_13.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_19 - ) subq_20 + ) subq_13 + ) subq_14 WHERE booking__is_instant - ) subq_21 - ) subq_22 + ) subq_15 + ) subq_16 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_24.listing - , subq_24.is_lux_latest + subq_18.listing + , subq_18.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.created_at__day + , subq_17.created_at__week + , subq_17.created_at__month + , subq_17.created_at__quarter + , subq_17.created_at__year + , subq_17.created_at__extract_year + , subq_17.created_at__extract_quarter + , subq_17.created_at__extract_month + , subq_17.created_at__extract_day + , subq_17.created_at__extract_dow + , subq_17.created_at__extract_doy + , subq_17.listing__ds__day + , subq_17.listing__ds__week + , subq_17.listing__ds__month + , subq_17.listing__ds__quarter + , subq_17.listing__ds__year + , subq_17.listing__ds__extract_year + , subq_17.listing__ds__extract_quarter + , subq_17.listing__ds__extract_month + , subq_17.listing__ds__extract_day + , subq_17.listing__ds__extract_dow + , subq_17.listing__ds__extract_doy + , subq_17.listing__created_at__day + , subq_17.listing__created_at__week + , subq_17.listing__created_at__month + , subq_17.listing__created_at__quarter + , subq_17.listing__created_at__year + , subq_17.listing__created_at__extract_year + , subq_17.listing__created_at__extract_quarter + , subq_17.listing__created_at__extract_month + , subq_17.listing__created_at__extract_day + , subq_17.listing__created_at__extract_dow + , subq_17.listing__created_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.user + , subq_17.listing__user + , subq_17.country_latest + , subq_17.is_lux_latest + , subq_17.capacity_latest + , subq_17.listing__country_latest + , subq_17.listing__is_lux_latest + , subq_17.listing__capacity_latest + , subq_17.listings + , subq_17.largest_listing + , subq_17.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_23 - ) subq_24 - ) subq_25 + ) subq_17 + ) subq_18 + ) subq_19 ON - subq_22.listing = subq_25.listing - ) subq_26 - ) subq_27 + subq_16.listing = subq_19.listing + ) subq_20 + ) subq_21 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 + ) subq_22 + ) subq_23 + ) subq_24 + ) subq_25 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_38.booking_value + subq_32.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_37.booking_value) AS booking_value + SUM(subq_31.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_36.booking_value + subq_30.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_35.booking__is_instant - , subq_35.booking_value + subq_29.booking__is_instant + , subq_29.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_34.booking__is_instant - , subq_34.booking_value + subq_28.booking__is_instant + , subq_28.booking_value FROM ( -- Constrain Output with WHERE SELECT - 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 + subq_27.ds__day + , subq_27.ds__week + , subq_27.ds__month + , subq_27.ds__quarter + , subq_27.ds__year + , subq_27.ds__extract_year + , subq_27.ds__extract_quarter + , subq_27.ds__extract_month + , subq_27.ds__extract_day + , subq_27.ds__extract_dow + , subq_27.ds__extract_doy + , subq_27.ds_partitioned__day + , subq_27.ds_partitioned__week + , subq_27.ds_partitioned__month + , subq_27.ds_partitioned__quarter + , subq_27.ds_partitioned__year + , subq_27.ds_partitioned__extract_year + , subq_27.ds_partitioned__extract_quarter + , subq_27.ds_partitioned__extract_month + , subq_27.ds_partitioned__extract_day + , subq_27.ds_partitioned__extract_dow + , subq_27.ds_partitioned__extract_doy + , subq_27.paid_at__day + , subq_27.paid_at__week + , subq_27.paid_at__month + , subq_27.paid_at__quarter + , subq_27.paid_at__year + , subq_27.paid_at__extract_year + , subq_27.paid_at__extract_quarter + , subq_27.paid_at__extract_month + , subq_27.paid_at__extract_day + , subq_27.paid_at__extract_dow + , subq_27.paid_at__extract_doy + , subq_27.booking__ds__day + , subq_27.booking__ds__week + , subq_27.booking__ds__month + , subq_27.booking__ds__quarter + , subq_27.booking__ds__year + , subq_27.booking__ds__extract_year + , subq_27.booking__ds__extract_quarter + , subq_27.booking__ds__extract_month + , subq_27.booking__ds__extract_day + , subq_27.booking__ds__extract_dow + , subq_27.booking__ds__extract_doy + , subq_27.booking__ds_partitioned__day + , subq_27.booking__ds_partitioned__week + , subq_27.booking__ds_partitioned__month + , subq_27.booking__ds_partitioned__quarter + , subq_27.booking__ds_partitioned__year + , subq_27.booking__ds_partitioned__extract_year + , subq_27.booking__ds_partitioned__extract_quarter + , subq_27.booking__ds_partitioned__extract_month + , subq_27.booking__ds_partitioned__extract_day + , subq_27.booking__ds_partitioned__extract_dow + , subq_27.booking__ds_partitioned__extract_doy + , subq_27.booking__paid_at__day + , subq_27.booking__paid_at__week + , subq_27.booking__paid_at__month + , subq_27.booking__paid_at__quarter + , subq_27.booking__paid_at__year + , subq_27.booking__paid_at__extract_year + , subq_27.booking__paid_at__extract_quarter + , subq_27.booking__paid_at__extract_month + , subq_27.booking__paid_at__extract_day + , subq_27.booking__paid_at__extract_dow + , subq_27.booking__paid_at__extract_doy + , subq_27.metric_time__day + , subq_27.metric_time__week + , subq_27.metric_time__month + , subq_27.metric_time__quarter + , subq_27.metric_time__year + , subq_27.metric_time__extract_year + , subq_27.metric_time__extract_quarter + , subq_27.metric_time__extract_month + , subq_27.metric_time__extract_day + , subq_27.metric_time__extract_dow + , subq_27.metric_time__extract_doy + , subq_27.listing + , subq_27.guest + , subq_27.host + , subq_27.booking__listing + , subq_27.booking__guest + , subq_27.booking__host + , subq_27.is_instant + , subq_27.booking__is_instant + , subq_27.bookings + , subq_27.instant_bookings + , subq_27.booking_value + , subq_27.max_booking_value + , subq_27.min_booking_value + , subq_27.bookers + , subq_27.average_booking_value + , subq_27.referred_bookings + , subq_27.median_booking_value + , subq_27.booking_value_p99 + , subq_27.discrete_booking_value_p99 + , subq_27.approximate_continuous_booking_value_p99 + , subq_27.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_26.ds__day + , subq_26.ds__week + , subq_26.ds__month + , subq_26.ds__quarter + , subq_26.ds__year + , subq_26.ds__extract_year + , subq_26.ds__extract_quarter + , subq_26.ds__extract_month + , subq_26.ds__extract_day + , subq_26.ds__extract_dow + , subq_26.ds__extract_doy + , subq_26.ds_partitioned__day + , subq_26.ds_partitioned__week + , subq_26.ds_partitioned__month + , subq_26.ds_partitioned__quarter + , subq_26.ds_partitioned__year + , subq_26.ds_partitioned__extract_year + , subq_26.ds_partitioned__extract_quarter + , subq_26.ds_partitioned__extract_month + , subq_26.ds_partitioned__extract_day + , subq_26.ds_partitioned__extract_dow + , subq_26.ds_partitioned__extract_doy + , subq_26.paid_at__day + , subq_26.paid_at__week + , subq_26.paid_at__month + , subq_26.paid_at__quarter + , subq_26.paid_at__year + , subq_26.paid_at__extract_year + , subq_26.paid_at__extract_quarter + , subq_26.paid_at__extract_month + , subq_26.paid_at__extract_day + , subq_26.paid_at__extract_dow + , subq_26.paid_at__extract_doy + , subq_26.booking__ds__day + , subq_26.booking__ds__week + , subq_26.booking__ds__month + , subq_26.booking__ds__quarter + , subq_26.booking__ds__year + , subq_26.booking__ds__extract_year + , subq_26.booking__ds__extract_quarter + , subq_26.booking__ds__extract_month + , subq_26.booking__ds__extract_day + , subq_26.booking__ds__extract_dow + , subq_26.booking__ds__extract_doy + , subq_26.booking__ds_partitioned__day + , subq_26.booking__ds_partitioned__week + , subq_26.booking__ds_partitioned__month + , subq_26.booking__ds_partitioned__quarter + , subq_26.booking__ds_partitioned__year + , subq_26.booking__ds_partitioned__extract_year + , subq_26.booking__ds_partitioned__extract_quarter + , subq_26.booking__ds_partitioned__extract_month + , subq_26.booking__ds_partitioned__extract_day + , subq_26.booking__ds_partitioned__extract_dow + , subq_26.booking__ds_partitioned__extract_doy + , subq_26.booking__paid_at__day + , subq_26.booking__paid_at__week + , subq_26.booking__paid_at__month + , subq_26.booking__paid_at__quarter + , subq_26.booking__paid_at__year + , subq_26.booking__paid_at__extract_year + , subq_26.booking__paid_at__extract_quarter + , subq_26.booking__paid_at__extract_month + , subq_26.booking__paid_at__extract_day + , subq_26.booking__paid_at__extract_dow + , subq_26.booking__paid_at__extract_doy + , subq_26.ds__day AS metric_time__day + , subq_26.ds__week AS metric_time__week + , subq_26.ds__month AS metric_time__month + , subq_26.ds__quarter AS metric_time__quarter + , subq_26.ds__year AS metric_time__year + , subq_26.ds__extract_year AS metric_time__extract_year + , subq_26.ds__extract_quarter AS metric_time__extract_quarter + , subq_26.ds__extract_month AS metric_time__extract_month + , subq_26.ds__extract_day AS metric_time__extract_day + , subq_26.ds__extract_dow AS metric_time__extract_dow + , subq_26.ds__extract_doy AS metric_time__extract_doy + , subq_26.listing + , subq_26.guest + , subq_26.host + , subq_26.booking__listing + , subq_26.booking__guest + , subq_26.booking__host + , subq_26.is_instant + , subq_26.booking__is_instant + , subq_26.bookings + , subq_26.instant_bookings + , subq_26.booking_value + , subq_26.max_booking_value + , subq_26.min_booking_value + , subq_26.bookers + , subq_26.average_booking_value + , subq_26.referred_bookings + , subq_26.median_booking_value + , subq_26.booking_value_p99 + , subq_26.discrete_booking_value_p99 + , subq_26.approximate_continuous_booking_value_p99 + , subq_26.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_32 - ) subq_33 + ) subq_26 + ) subq_27 WHERE booking__is_instant - ) subq_34 - ) subq_35 + ) subq_28 + ) subq_29 WHERE booking__is_instant - ) subq_36 - ) subq_37 - ) subq_38 - ) subq_39 - ) subq_40 -) subq_41 + ) subq_30 + ) subq_31 + ) subq_32 + ) subq_33 + ) subq_34 +) subq_35 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0_optimized.sql index eab0cc218b..6a8c176c6c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_60.average_booking_value) AS average_booking_value - , MAX(subq_73.bookings) AS bookings - , MAX(subq_81.booking_value) AS booking_value + MAX(subq_48.average_booking_value) AS average_booking_value + , MAX(subq_61.bookings) AS bookings + , MAX(subq_69.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_51.booking__is_instant AS booking__is_instant + subq_39.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_51.average_booking_value AS average_booking_value + , subq_39.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_49 + ) subq_37 WHERE booking__is_instant - ) subq_51 + ) subq_39 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_51.listing = listings_latest_src_28000.listing_id - ) subq_56 + subq_39.listing = listings_latest_src_28000.listing_id + ) subq_44 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_60 + ) subq_48 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_64.booking__is_instant AS booking__is_instant + subq_52.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_64.bookings AS bookings + , subq_52.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_62 + ) subq_50 WHERE booking__is_instant - ) subq_64 + ) subq_52 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_64.listing = listings_latest_src_28000.listing_id - ) subq_69 + subq_52.listing = listings_latest_src_28000.listing_id + ) subq_57 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_73 + ) subq_61 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_75 + ) subq_63 WHERE booking__is_instant - ) subq_77 + ) subq_65 WHERE booking__is_instant - ) subq_81 - ) subq_82 -) subq_83 + ) subq_69 + ) subq_70 +) subq_71 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0.sql index dfcc81fb82..959875a41d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0.sql @@ -8,248 +8,248 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_18.average_booking_value) AS average_booking_value - , MAX(subq_31.bookings) AS bookings - , MAX(subq_39.booking_value) AS booking_value + MAX(subq_12.average_booking_value) AS average_booking_value + , MAX(subq_25.bookings) AS bookings + , MAX(subq_33.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_17.average_booking_value + subq_11.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_16.average_booking_value) AS average_booking_value + AVG(subq_10.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_15.average_booking_value + subq_9.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_14.booking__is_instant - , subq_14.listing__is_lux_latest - , subq_14.average_booking_value + subq_8.booking__is_instant + , subq_8.listing__is_lux_latest + , subq_8.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant - , subq_13.listing__is_lux_latest - , subq_13.average_booking_value + subq_7.booking__is_instant + , subq_7.listing__is_lux_latest + , subq_7.average_booking_value FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.listing AS listing + , subq_3.booking__is_instant AS booking__is_instant + , subq_6.is_lux_latest AS listing__is_lux_latest + , subq_3.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_8.listing - , subq_8.booking__is_instant - , subq_8.average_booking_value + subq_2.listing + , subq_2.booking__is_instant + , subq_2.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_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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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_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 @@ -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_6 - ) subq_7 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_11.listing - , subq_11.is_lux_latest + subq_5.listing + , subq_5.is_lux_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_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.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_10 - ) subq_11 - ) subq_12 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_9.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_30.bookings + subq_24.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_29.bookings) AS bookings + SUM(subq_23.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_28.bookings + subq_22.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_27.booking__is_instant - , subq_27.listing__is_lux_latest - , subq_27.bookings + subq_21.booking__is_instant + , subq_21.listing__is_lux_latest + , subq_21.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_26.booking__is_instant - , subq_26.listing__is_lux_latest - , subq_26.bookings + subq_20.booking__is_instant + , subq_20.listing__is_lux_latest + , subq_20.bookings FROM ( -- Join Standard Outputs SELECT - 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 + subq_16.listing AS listing + , subq_16.booking__is_instant AS booking__is_instant + , subq_19.is_lux_latest AS listing__is_lux_latest + , subq_16.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_21.listing - , subq_21.booking__is_instant - , subq_21.bookings + subq_15.listing + , subq_15.booking__is_instant + , subq_15.bookings FROM ( -- Constrain Output with WHERE SELECT - 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 + 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.metric_time__day + , subq_14.metric_time__week + , subq_14.metric_time__month + , subq_14.metric_time__quarter + , subq_14.metric_time__year + , subq_14.metric_time__extract_year + , subq_14.metric_time__extract_quarter + , subq_14.metric_time__extract_month + , subq_14.metric_time__extract_day + , subq_14.metric_time__extract_dow + , subq_14.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 FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.max_booking_value + , subq_13.min_booking_value + , subq_13.bookers + , subq_13.average_booking_value + , subq_13.referred_bookings + , subq_13.median_booking_value + , subq_13.booking_value_p99 + , subq_13.discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 + , subq_13.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_19 - ) subq_20 + ) subq_13 + ) subq_14 WHERE booking__is_instant - ) subq_21 - ) subq_22 + ) subq_15 + ) subq_16 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_24.listing - , subq_24.is_lux_latest + subq_18.listing + , subq_18.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.created_at__day + , subq_17.created_at__week + , subq_17.created_at__month + , subq_17.created_at__quarter + , subq_17.created_at__year + , subq_17.created_at__extract_year + , subq_17.created_at__extract_quarter + , subq_17.created_at__extract_month + , subq_17.created_at__extract_day + , subq_17.created_at__extract_dow + , subq_17.created_at__extract_doy + , subq_17.listing__ds__day + , subq_17.listing__ds__week + , subq_17.listing__ds__month + , subq_17.listing__ds__quarter + , subq_17.listing__ds__year + , subq_17.listing__ds__extract_year + , subq_17.listing__ds__extract_quarter + , subq_17.listing__ds__extract_month + , subq_17.listing__ds__extract_day + , subq_17.listing__ds__extract_dow + , subq_17.listing__ds__extract_doy + , subq_17.listing__created_at__day + , subq_17.listing__created_at__week + , subq_17.listing__created_at__month + , subq_17.listing__created_at__quarter + , subq_17.listing__created_at__year + , subq_17.listing__created_at__extract_year + , subq_17.listing__created_at__extract_quarter + , subq_17.listing__created_at__extract_month + , subq_17.listing__created_at__extract_day + , subq_17.listing__created_at__extract_dow + , subq_17.listing__created_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.user + , subq_17.listing__user + , subq_17.country_latest + , subq_17.is_lux_latest + , subq_17.capacity_latest + , subq_17.listing__country_latest + , subq_17.listing__is_lux_latest + , subq_17.listing__capacity_latest + , subq_17.listings + , subq_17.largest_listing + , subq_17.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_23 - ) subq_24 - ) subq_25 + ) subq_17 + ) subq_18 + ) subq_19 ON - subq_22.listing = subq_25.listing - ) subq_26 - ) subq_27 + subq_16.listing = subq_19.listing + ) subq_20 + ) subq_21 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 + ) subq_22 + ) subq_23 + ) subq_24 + ) subq_25 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_38.booking_value + subq_32.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_37.booking_value) AS booking_value + SUM(subq_31.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_36.booking_value + subq_30.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_35.booking__is_instant - , subq_35.booking_value + subq_29.booking__is_instant + , subq_29.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_34.booking__is_instant - , subq_34.booking_value + subq_28.booking__is_instant + , subq_28.booking_value FROM ( -- Constrain Output with WHERE SELECT - 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 + subq_27.ds__day + , subq_27.ds__week + , subq_27.ds__month + , subq_27.ds__quarter + , subq_27.ds__year + , subq_27.ds__extract_year + , subq_27.ds__extract_quarter + , subq_27.ds__extract_month + , subq_27.ds__extract_day + , subq_27.ds__extract_dow + , subq_27.ds__extract_doy + , subq_27.ds_partitioned__day + , subq_27.ds_partitioned__week + , subq_27.ds_partitioned__month + , subq_27.ds_partitioned__quarter + , subq_27.ds_partitioned__year + , subq_27.ds_partitioned__extract_year + , subq_27.ds_partitioned__extract_quarter + , subq_27.ds_partitioned__extract_month + , subq_27.ds_partitioned__extract_day + , subq_27.ds_partitioned__extract_dow + , subq_27.ds_partitioned__extract_doy + , subq_27.paid_at__day + , subq_27.paid_at__week + , subq_27.paid_at__month + , subq_27.paid_at__quarter + , subq_27.paid_at__year + , subq_27.paid_at__extract_year + , subq_27.paid_at__extract_quarter + , subq_27.paid_at__extract_month + , subq_27.paid_at__extract_day + , subq_27.paid_at__extract_dow + , subq_27.paid_at__extract_doy + , subq_27.booking__ds__day + , subq_27.booking__ds__week + , subq_27.booking__ds__month + , subq_27.booking__ds__quarter + , subq_27.booking__ds__year + , subq_27.booking__ds__extract_year + , subq_27.booking__ds__extract_quarter + , subq_27.booking__ds__extract_month + , subq_27.booking__ds__extract_day + , subq_27.booking__ds__extract_dow + , subq_27.booking__ds__extract_doy + , subq_27.booking__ds_partitioned__day + , subq_27.booking__ds_partitioned__week + , subq_27.booking__ds_partitioned__month + , subq_27.booking__ds_partitioned__quarter + , subq_27.booking__ds_partitioned__year + , subq_27.booking__ds_partitioned__extract_year + , subq_27.booking__ds_partitioned__extract_quarter + , subq_27.booking__ds_partitioned__extract_month + , subq_27.booking__ds_partitioned__extract_day + , subq_27.booking__ds_partitioned__extract_dow + , subq_27.booking__ds_partitioned__extract_doy + , subq_27.booking__paid_at__day + , subq_27.booking__paid_at__week + , subq_27.booking__paid_at__month + , subq_27.booking__paid_at__quarter + , subq_27.booking__paid_at__year + , subq_27.booking__paid_at__extract_year + , subq_27.booking__paid_at__extract_quarter + , subq_27.booking__paid_at__extract_month + , subq_27.booking__paid_at__extract_day + , subq_27.booking__paid_at__extract_dow + , subq_27.booking__paid_at__extract_doy + , subq_27.metric_time__day + , subq_27.metric_time__week + , subq_27.metric_time__month + , subq_27.metric_time__quarter + , subq_27.metric_time__year + , subq_27.metric_time__extract_year + , subq_27.metric_time__extract_quarter + , subq_27.metric_time__extract_month + , subq_27.metric_time__extract_day + , subq_27.metric_time__extract_dow + , subq_27.metric_time__extract_doy + , subq_27.listing + , subq_27.guest + , subq_27.host + , subq_27.booking__listing + , subq_27.booking__guest + , subq_27.booking__host + , subq_27.is_instant + , subq_27.booking__is_instant + , subq_27.bookings + , subq_27.instant_bookings + , subq_27.booking_value + , subq_27.max_booking_value + , subq_27.min_booking_value + , subq_27.bookers + , subq_27.average_booking_value + , subq_27.referred_bookings + , subq_27.median_booking_value + , subq_27.booking_value_p99 + , subq_27.discrete_booking_value_p99 + , subq_27.approximate_continuous_booking_value_p99 + , subq_27.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_26.ds__day + , subq_26.ds__week + , subq_26.ds__month + , subq_26.ds__quarter + , subq_26.ds__year + , subq_26.ds__extract_year + , subq_26.ds__extract_quarter + , subq_26.ds__extract_month + , subq_26.ds__extract_day + , subq_26.ds__extract_dow + , subq_26.ds__extract_doy + , subq_26.ds_partitioned__day + , subq_26.ds_partitioned__week + , subq_26.ds_partitioned__month + , subq_26.ds_partitioned__quarter + , subq_26.ds_partitioned__year + , subq_26.ds_partitioned__extract_year + , subq_26.ds_partitioned__extract_quarter + , subq_26.ds_partitioned__extract_month + , subq_26.ds_partitioned__extract_day + , subq_26.ds_partitioned__extract_dow + , subq_26.ds_partitioned__extract_doy + , subq_26.paid_at__day + , subq_26.paid_at__week + , subq_26.paid_at__month + , subq_26.paid_at__quarter + , subq_26.paid_at__year + , subq_26.paid_at__extract_year + , subq_26.paid_at__extract_quarter + , subq_26.paid_at__extract_month + , subq_26.paid_at__extract_day + , subq_26.paid_at__extract_dow + , subq_26.paid_at__extract_doy + , subq_26.booking__ds__day + , subq_26.booking__ds__week + , subq_26.booking__ds__month + , subq_26.booking__ds__quarter + , subq_26.booking__ds__year + , subq_26.booking__ds__extract_year + , subq_26.booking__ds__extract_quarter + , subq_26.booking__ds__extract_month + , subq_26.booking__ds__extract_day + , subq_26.booking__ds__extract_dow + , subq_26.booking__ds__extract_doy + , subq_26.booking__ds_partitioned__day + , subq_26.booking__ds_partitioned__week + , subq_26.booking__ds_partitioned__month + , subq_26.booking__ds_partitioned__quarter + , subq_26.booking__ds_partitioned__year + , subq_26.booking__ds_partitioned__extract_year + , subq_26.booking__ds_partitioned__extract_quarter + , subq_26.booking__ds_partitioned__extract_month + , subq_26.booking__ds_partitioned__extract_day + , subq_26.booking__ds_partitioned__extract_dow + , subq_26.booking__ds_partitioned__extract_doy + , subq_26.booking__paid_at__day + , subq_26.booking__paid_at__week + , subq_26.booking__paid_at__month + , subq_26.booking__paid_at__quarter + , subq_26.booking__paid_at__year + , subq_26.booking__paid_at__extract_year + , subq_26.booking__paid_at__extract_quarter + , subq_26.booking__paid_at__extract_month + , subq_26.booking__paid_at__extract_day + , subq_26.booking__paid_at__extract_dow + , subq_26.booking__paid_at__extract_doy + , subq_26.ds__day AS metric_time__day + , subq_26.ds__week AS metric_time__week + , subq_26.ds__month AS metric_time__month + , subq_26.ds__quarter AS metric_time__quarter + , subq_26.ds__year AS metric_time__year + , subq_26.ds__extract_year AS metric_time__extract_year + , subq_26.ds__extract_quarter AS metric_time__extract_quarter + , subq_26.ds__extract_month AS metric_time__extract_month + , subq_26.ds__extract_day AS metric_time__extract_day + , subq_26.ds__extract_dow AS metric_time__extract_dow + , subq_26.ds__extract_doy AS metric_time__extract_doy + , subq_26.listing + , subq_26.guest + , subq_26.host + , subq_26.booking__listing + , subq_26.booking__guest + , subq_26.booking__host + , subq_26.is_instant + , subq_26.booking__is_instant + , subq_26.bookings + , subq_26.instant_bookings + , subq_26.booking_value + , subq_26.max_booking_value + , subq_26.min_booking_value + , subq_26.bookers + , subq_26.average_booking_value + , subq_26.referred_bookings + , subq_26.median_booking_value + , subq_26.booking_value_p99 + , subq_26.discrete_booking_value_p99 + , subq_26.approximate_continuous_booking_value_p99 + , subq_26.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_32 - ) subq_33 + ) subq_26 + ) subq_27 WHERE booking__is_instant - ) subq_34 - ) subq_35 + ) subq_28 + ) subq_29 WHERE booking__is_instant - ) subq_36 - ) subq_37 - ) subq_38 - ) subq_39 - ) subq_40 -) subq_41 + ) subq_30 + ) subq_31 + ) subq_32 + ) subq_33 + ) subq_34 +) subq_35 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0_optimized.sql index eab0cc218b..6a8c176c6c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_60.average_booking_value) AS average_booking_value - , MAX(subq_73.bookings) AS bookings - , MAX(subq_81.booking_value) AS booking_value + MAX(subq_48.average_booking_value) AS average_booking_value + , MAX(subq_61.bookings) AS bookings + , MAX(subq_69.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_51.booking__is_instant AS booking__is_instant + subq_39.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_51.average_booking_value AS average_booking_value + , subq_39.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_49 + ) subq_37 WHERE booking__is_instant - ) subq_51 + ) subq_39 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_51.listing = listings_latest_src_28000.listing_id - ) subq_56 + subq_39.listing = listings_latest_src_28000.listing_id + ) subq_44 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_60 + ) subq_48 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_64.booking__is_instant AS booking__is_instant + subq_52.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_64.bookings AS bookings + , subq_52.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_62 + ) subq_50 WHERE booking__is_instant - ) subq_64 + ) subq_52 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_64.listing = listings_latest_src_28000.listing_id - ) subq_69 + subq_52.listing = listings_latest_src_28000.listing_id + ) subq_57 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_73 + ) subq_61 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_75 + ) subq_63 WHERE booking__is_instant - ) subq_77 + ) subq_65 WHERE booking__is_instant - ) subq_81 - ) subq_82 -) subq_83 + ) subq_69 + ) subq_70 +) subq_71 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0.sql index 6fea622708..e9d6a5c56b 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0.sql @@ -8,248 +8,248 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_18.average_booking_value) AS average_booking_value - , MAX(subq_31.bookings) AS bookings - , MAX(subq_39.booking_value) AS booking_value + MAX(subq_12.average_booking_value) AS average_booking_value + , MAX(subq_25.bookings) AS bookings + , MAX(subq_33.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_17.average_booking_value + subq_11.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_16.average_booking_value) AS average_booking_value + AVG(subq_10.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_15.average_booking_value + subq_9.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_14.booking__is_instant - , subq_14.listing__is_lux_latest - , subq_14.average_booking_value + subq_8.booking__is_instant + , subq_8.listing__is_lux_latest + , subq_8.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant - , subq_13.listing__is_lux_latest - , subq_13.average_booking_value + subq_7.booking__is_instant + , subq_7.listing__is_lux_latest + , subq_7.average_booking_value FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.listing AS listing + , subq_3.booking__is_instant AS booking__is_instant + , subq_6.is_lux_latest AS listing__is_lux_latest + , subq_3.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_8.listing - , subq_8.booking__is_instant - , subq_8.average_booking_value + subq_2.listing + , subq_2.booking__is_instant + , subq_2.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_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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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_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 @@ -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_6 - ) subq_7 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_11.listing - , subq_11.is_lux_latest + subq_5.listing + , subq_5.is_lux_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_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.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_10 - ) subq_11 - ) subq_12 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_9.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 + ) subq_9 + ) subq_10 + ) subq_11 + ) subq_12 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_30.bookings + subq_24.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_29.bookings) AS bookings + SUM(subq_23.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_28.bookings + subq_22.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_27.booking__is_instant - , subq_27.listing__is_lux_latest - , subq_27.bookings + subq_21.booking__is_instant + , subq_21.listing__is_lux_latest + , subq_21.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_26.booking__is_instant - , subq_26.listing__is_lux_latest - , subq_26.bookings + subq_20.booking__is_instant + , subq_20.listing__is_lux_latest + , subq_20.bookings FROM ( -- Join Standard Outputs SELECT - 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 + subq_16.listing AS listing + , subq_16.booking__is_instant AS booking__is_instant + , subq_19.is_lux_latest AS listing__is_lux_latest + , subq_16.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_21.listing - , subq_21.booking__is_instant - , subq_21.bookings + subq_15.listing + , subq_15.booking__is_instant + , subq_15.bookings FROM ( -- Constrain Output with WHERE SELECT - 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 + 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.metric_time__day + , subq_14.metric_time__week + , subq_14.metric_time__month + , subq_14.metric_time__quarter + , subq_14.metric_time__year + , subq_14.metric_time__extract_year + , subq_14.metric_time__extract_quarter + , subq_14.metric_time__extract_month + , subq_14.metric_time__extract_day + , subq_14.metric_time__extract_dow + , subq_14.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 FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_13.ds__day + , subq_13.ds__week + , subq_13.ds__month + , subq_13.ds__quarter + , subq_13.ds__year + , subq_13.ds__extract_year + , subq_13.ds__extract_quarter + , subq_13.ds__extract_month + , subq_13.ds__extract_day + , subq_13.ds__extract_dow + , subq_13.ds__extract_doy + , subq_13.ds_partitioned__day + , subq_13.ds_partitioned__week + , subq_13.ds_partitioned__month + , subq_13.ds_partitioned__quarter + , subq_13.ds_partitioned__year + , subq_13.ds_partitioned__extract_year + , subq_13.ds_partitioned__extract_quarter + , subq_13.ds_partitioned__extract_month + , subq_13.ds_partitioned__extract_day + , subq_13.ds_partitioned__extract_dow + , subq_13.ds_partitioned__extract_doy + , subq_13.paid_at__day + , subq_13.paid_at__week + , subq_13.paid_at__month + , subq_13.paid_at__quarter + , subq_13.paid_at__year + , subq_13.paid_at__extract_year + , subq_13.paid_at__extract_quarter + , subq_13.paid_at__extract_month + , subq_13.paid_at__extract_day + , subq_13.paid_at__extract_dow + , subq_13.paid_at__extract_doy + , subq_13.booking__ds__day + , subq_13.booking__ds__week + , subq_13.booking__ds__month + , subq_13.booking__ds__quarter + , subq_13.booking__ds__year + , subq_13.booking__ds__extract_year + , subq_13.booking__ds__extract_quarter + , subq_13.booking__ds__extract_month + , subq_13.booking__ds__extract_day + , subq_13.booking__ds__extract_dow + , subq_13.booking__ds__extract_doy + , subq_13.booking__ds_partitioned__day + , subq_13.booking__ds_partitioned__week + , subq_13.booking__ds_partitioned__month + , subq_13.booking__ds_partitioned__quarter + , subq_13.booking__ds_partitioned__year + , subq_13.booking__ds_partitioned__extract_year + , subq_13.booking__ds_partitioned__extract_quarter + , subq_13.booking__ds_partitioned__extract_month + , subq_13.booking__ds_partitioned__extract_day + , subq_13.booking__ds_partitioned__extract_dow + , subq_13.booking__ds_partitioned__extract_doy + , subq_13.booking__paid_at__day + , subq_13.booking__paid_at__week + , subq_13.booking__paid_at__month + , subq_13.booking__paid_at__quarter + , subq_13.booking__paid_at__year + , subq_13.booking__paid_at__extract_year + , subq_13.booking__paid_at__extract_quarter + , subq_13.booking__paid_at__extract_month + , subq_13.booking__paid_at__extract_day + , subq_13.booking__paid_at__extract_dow + , subq_13.booking__paid_at__extract_doy + , subq_13.ds__day AS metric_time__day + , subq_13.ds__week AS metric_time__week + , subq_13.ds__month AS metric_time__month + , subq_13.ds__quarter AS metric_time__quarter + , subq_13.ds__year AS metric_time__year + , subq_13.ds__extract_year AS metric_time__extract_year + , subq_13.ds__extract_quarter AS metric_time__extract_quarter + , subq_13.ds__extract_month AS metric_time__extract_month + , subq_13.ds__extract_day AS metric_time__extract_day + , subq_13.ds__extract_dow AS metric_time__extract_dow + , subq_13.ds__extract_doy AS metric_time__extract_doy + , subq_13.listing + , subq_13.guest + , subq_13.host + , subq_13.booking__listing + , subq_13.booking__guest + , subq_13.booking__host + , subq_13.is_instant + , subq_13.booking__is_instant + , subq_13.bookings + , subq_13.instant_bookings + , subq_13.booking_value + , subq_13.max_booking_value + , subq_13.min_booking_value + , subq_13.bookers + , subq_13.average_booking_value + , subq_13.referred_bookings + , subq_13.median_booking_value + , subq_13.booking_value_p99 + , subq_13.discrete_booking_value_p99 + , subq_13.approximate_continuous_booking_value_p99 + , subq_13.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_19 - ) subq_20 + ) subq_13 + ) subq_14 WHERE booking__is_instant - ) subq_21 - ) subq_22 + ) subq_15 + ) subq_16 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_24.listing - , subq_24.is_lux_latest + subq_18.listing + , subq_18.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - 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 + subq_17.ds__day + , subq_17.ds__week + , subq_17.ds__month + , subq_17.ds__quarter + , subq_17.ds__year + , subq_17.ds__extract_year + , subq_17.ds__extract_quarter + , subq_17.ds__extract_month + , subq_17.ds__extract_day + , subq_17.ds__extract_dow + , subq_17.ds__extract_doy + , subq_17.created_at__day + , subq_17.created_at__week + , subq_17.created_at__month + , subq_17.created_at__quarter + , subq_17.created_at__year + , subq_17.created_at__extract_year + , subq_17.created_at__extract_quarter + , subq_17.created_at__extract_month + , subq_17.created_at__extract_day + , subq_17.created_at__extract_dow + , subq_17.created_at__extract_doy + , subq_17.listing__ds__day + , subq_17.listing__ds__week + , subq_17.listing__ds__month + , subq_17.listing__ds__quarter + , subq_17.listing__ds__year + , subq_17.listing__ds__extract_year + , subq_17.listing__ds__extract_quarter + , subq_17.listing__ds__extract_month + , subq_17.listing__ds__extract_day + , subq_17.listing__ds__extract_dow + , subq_17.listing__ds__extract_doy + , subq_17.listing__created_at__day + , subq_17.listing__created_at__week + , subq_17.listing__created_at__month + , subq_17.listing__created_at__quarter + , subq_17.listing__created_at__year + , subq_17.listing__created_at__extract_year + , subq_17.listing__created_at__extract_quarter + , subq_17.listing__created_at__extract_month + , subq_17.listing__created_at__extract_day + , subq_17.listing__created_at__extract_dow + , subq_17.listing__created_at__extract_doy + , subq_17.ds__day AS metric_time__day + , subq_17.ds__week AS metric_time__week + , subq_17.ds__month AS metric_time__month + , subq_17.ds__quarter AS metric_time__quarter + , subq_17.ds__year AS metric_time__year + , subq_17.ds__extract_year AS metric_time__extract_year + , subq_17.ds__extract_quarter AS metric_time__extract_quarter + , subq_17.ds__extract_month AS metric_time__extract_month + , subq_17.ds__extract_day AS metric_time__extract_day + , subq_17.ds__extract_dow AS metric_time__extract_dow + , subq_17.ds__extract_doy AS metric_time__extract_doy + , subq_17.listing + , subq_17.user + , subq_17.listing__user + , subq_17.country_latest + , subq_17.is_lux_latest + , subq_17.capacity_latest + , subq_17.listing__country_latest + , subq_17.listing__is_lux_latest + , subq_17.listing__capacity_latest + , subq_17.listings + , subq_17.largest_listing + , subq_17.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_23 - ) subq_24 - ) subq_25 + ) subq_17 + ) subq_18 + ) subq_19 ON - subq_22.listing = subq_25.listing - ) subq_26 - ) subq_27 + subq_16.listing = subq_19.listing + ) subq_20 + ) subq_21 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 + ) subq_22 + ) subq_23 + ) subq_24 + ) subq_25 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_38.booking_value + subq_32.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_37.booking_value) AS booking_value + SUM(subq_31.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_36.booking_value + subq_30.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_35.booking__is_instant - , subq_35.booking_value + subq_29.booking__is_instant + , subq_29.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_34.booking__is_instant - , subq_34.booking_value + subq_28.booking__is_instant + , subq_28.booking_value FROM ( -- Constrain Output with WHERE SELECT - 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 + subq_27.ds__day + , subq_27.ds__week + , subq_27.ds__month + , subq_27.ds__quarter + , subq_27.ds__year + , subq_27.ds__extract_year + , subq_27.ds__extract_quarter + , subq_27.ds__extract_month + , subq_27.ds__extract_day + , subq_27.ds__extract_dow + , subq_27.ds__extract_doy + , subq_27.ds_partitioned__day + , subq_27.ds_partitioned__week + , subq_27.ds_partitioned__month + , subq_27.ds_partitioned__quarter + , subq_27.ds_partitioned__year + , subq_27.ds_partitioned__extract_year + , subq_27.ds_partitioned__extract_quarter + , subq_27.ds_partitioned__extract_month + , subq_27.ds_partitioned__extract_day + , subq_27.ds_partitioned__extract_dow + , subq_27.ds_partitioned__extract_doy + , subq_27.paid_at__day + , subq_27.paid_at__week + , subq_27.paid_at__month + , subq_27.paid_at__quarter + , subq_27.paid_at__year + , subq_27.paid_at__extract_year + , subq_27.paid_at__extract_quarter + , subq_27.paid_at__extract_month + , subq_27.paid_at__extract_day + , subq_27.paid_at__extract_dow + , subq_27.paid_at__extract_doy + , subq_27.booking__ds__day + , subq_27.booking__ds__week + , subq_27.booking__ds__month + , subq_27.booking__ds__quarter + , subq_27.booking__ds__year + , subq_27.booking__ds__extract_year + , subq_27.booking__ds__extract_quarter + , subq_27.booking__ds__extract_month + , subq_27.booking__ds__extract_day + , subq_27.booking__ds__extract_dow + , subq_27.booking__ds__extract_doy + , subq_27.booking__ds_partitioned__day + , subq_27.booking__ds_partitioned__week + , subq_27.booking__ds_partitioned__month + , subq_27.booking__ds_partitioned__quarter + , subq_27.booking__ds_partitioned__year + , subq_27.booking__ds_partitioned__extract_year + , subq_27.booking__ds_partitioned__extract_quarter + , subq_27.booking__ds_partitioned__extract_month + , subq_27.booking__ds_partitioned__extract_day + , subq_27.booking__ds_partitioned__extract_dow + , subq_27.booking__ds_partitioned__extract_doy + , subq_27.booking__paid_at__day + , subq_27.booking__paid_at__week + , subq_27.booking__paid_at__month + , subq_27.booking__paid_at__quarter + , subq_27.booking__paid_at__year + , subq_27.booking__paid_at__extract_year + , subq_27.booking__paid_at__extract_quarter + , subq_27.booking__paid_at__extract_month + , subq_27.booking__paid_at__extract_day + , subq_27.booking__paid_at__extract_dow + , subq_27.booking__paid_at__extract_doy + , subq_27.metric_time__day + , subq_27.metric_time__week + , subq_27.metric_time__month + , subq_27.metric_time__quarter + , subq_27.metric_time__year + , subq_27.metric_time__extract_year + , subq_27.metric_time__extract_quarter + , subq_27.metric_time__extract_month + , subq_27.metric_time__extract_day + , subq_27.metric_time__extract_dow + , subq_27.metric_time__extract_doy + , subq_27.listing + , subq_27.guest + , subq_27.host + , subq_27.booking__listing + , subq_27.booking__guest + , subq_27.booking__host + , subq_27.is_instant + , subq_27.booking__is_instant + , subq_27.bookings + , subq_27.instant_bookings + , subq_27.booking_value + , subq_27.max_booking_value + , subq_27.min_booking_value + , subq_27.bookers + , subq_27.average_booking_value + , subq_27.referred_bookings + , subq_27.median_booking_value + , subq_27.booking_value_p99 + , subq_27.discrete_booking_value_p99 + , subq_27.approximate_continuous_booking_value_p99 + , subq_27.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_26.ds__day + , subq_26.ds__week + , subq_26.ds__month + , subq_26.ds__quarter + , subq_26.ds__year + , subq_26.ds__extract_year + , subq_26.ds__extract_quarter + , subq_26.ds__extract_month + , subq_26.ds__extract_day + , subq_26.ds__extract_dow + , subq_26.ds__extract_doy + , subq_26.ds_partitioned__day + , subq_26.ds_partitioned__week + , subq_26.ds_partitioned__month + , subq_26.ds_partitioned__quarter + , subq_26.ds_partitioned__year + , subq_26.ds_partitioned__extract_year + , subq_26.ds_partitioned__extract_quarter + , subq_26.ds_partitioned__extract_month + , subq_26.ds_partitioned__extract_day + , subq_26.ds_partitioned__extract_dow + , subq_26.ds_partitioned__extract_doy + , subq_26.paid_at__day + , subq_26.paid_at__week + , subq_26.paid_at__month + , subq_26.paid_at__quarter + , subq_26.paid_at__year + , subq_26.paid_at__extract_year + , subq_26.paid_at__extract_quarter + , subq_26.paid_at__extract_month + , subq_26.paid_at__extract_day + , subq_26.paid_at__extract_dow + , subq_26.paid_at__extract_doy + , subq_26.booking__ds__day + , subq_26.booking__ds__week + , subq_26.booking__ds__month + , subq_26.booking__ds__quarter + , subq_26.booking__ds__year + , subq_26.booking__ds__extract_year + , subq_26.booking__ds__extract_quarter + , subq_26.booking__ds__extract_month + , subq_26.booking__ds__extract_day + , subq_26.booking__ds__extract_dow + , subq_26.booking__ds__extract_doy + , subq_26.booking__ds_partitioned__day + , subq_26.booking__ds_partitioned__week + , subq_26.booking__ds_partitioned__month + , subq_26.booking__ds_partitioned__quarter + , subq_26.booking__ds_partitioned__year + , subq_26.booking__ds_partitioned__extract_year + , subq_26.booking__ds_partitioned__extract_quarter + , subq_26.booking__ds_partitioned__extract_month + , subq_26.booking__ds_partitioned__extract_day + , subq_26.booking__ds_partitioned__extract_dow + , subq_26.booking__ds_partitioned__extract_doy + , subq_26.booking__paid_at__day + , subq_26.booking__paid_at__week + , subq_26.booking__paid_at__month + , subq_26.booking__paid_at__quarter + , subq_26.booking__paid_at__year + , subq_26.booking__paid_at__extract_year + , subq_26.booking__paid_at__extract_quarter + , subq_26.booking__paid_at__extract_month + , subq_26.booking__paid_at__extract_day + , subq_26.booking__paid_at__extract_dow + , subq_26.booking__paid_at__extract_doy + , subq_26.ds__day AS metric_time__day + , subq_26.ds__week AS metric_time__week + , subq_26.ds__month AS metric_time__month + , subq_26.ds__quarter AS metric_time__quarter + , subq_26.ds__year AS metric_time__year + , subq_26.ds__extract_year AS metric_time__extract_year + , subq_26.ds__extract_quarter AS metric_time__extract_quarter + , subq_26.ds__extract_month AS metric_time__extract_month + , subq_26.ds__extract_day AS metric_time__extract_day + , subq_26.ds__extract_dow AS metric_time__extract_dow + , subq_26.ds__extract_doy AS metric_time__extract_doy + , subq_26.listing + , subq_26.guest + , subq_26.host + , subq_26.booking__listing + , subq_26.booking__guest + , subq_26.booking__host + , subq_26.is_instant + , subq_26.booking__is_instant + , subq_26.bookings + , subq_26.instant_bookings + , subq_26.booking_value + , subq_26.max_booking_value + , subq_26.min_booking_value + , subq_26.bookers + , subq_26.average_booking_value + , subq_26.referred_bookings + , subq_26.median_booking_value + , subq_26.booking_value_p99 + , subq_26.discrete_booking_value_p99 + , subq_26.approximate_continuous_booking_value_p99 + , subq_26.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_32 - ) subq_33 + ) subq_26 + ) subq_27 WHERE booking__is_instant - ) subq_34 - ) subq_35 + ) subq_28 + ) subq_29 WHERE booking__is_instant - ) subq_36 - ) subq_37 - ) subq_38 - ) subq_39 - ) subq_40 -) subq_41 + ) subq_30 + ) subq_31 + ) subq_32 + ) subq_33 + ) subq_34 +) subq_35 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0_optimized.sql index eab0cc218b..6a8c176c6c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_60.average_booking_value) AS average_booking_value - , MAX(subq_73.bookings) AS bookings - , MAX(subq_81.booking_value) AS booking_value + MAX(subq_48.average_booking_value) AS average_booking_value + , MAX(subq_61.bookings) AS bookings + , MAX(subq_69.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_51.booking__is_instant AS booking__is_instant + subq_39.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_51.average_booking_value AS average_booking_value + , subq_39.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_49 + ) subq_37 WHERE booking__is_instant - ) subq_51 + ) subq_39 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_51.listing = listings_latest_src_28000.listing_id - ) subq_56 + subq_39.listing = listings_latest_src_28000.listing_id + ) subq_44 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_60 + ) subq_48 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_64.booking__is_instant AS booking__is_instant + subq_52.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_64.bookings AS bookings + , subq_52.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_62 + ) subq_50 WHERE booking__is_instant - ) subq_64 + ) subq_52 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_64.listing = listings_latest_src_28000.listing_id - ) subq_69 + subq_52.listing = listings_latest_src_28000.listing_id + ) subq_57 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_73 + ) subq_61 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_75 + ) subq_63 WHERE booking__is_instant - ) subq_77 + ) subq_65 WHERE booking__is_instant - ) subq_81 - ) subq_82 -) subq_83 + ) subq_69 + ) subq_70 +) subq_71 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0.sql index 5a0a13a43b..4a7eb2a2b0 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0.sql @@ -1,246 +1,246 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 + subq_10.metric_time__day + , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_11.metric_time__day - , subq_11.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_8.metric_time__day + , subq_8.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.bookings AS bookings FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - WHERE subq_9.ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_8 + subq_7.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_7 + WHERE subq_7.ds BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , SUM(subq_6.bookings) AS bookings + subq_4.metric_time__day + , SUM(subq_4.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.bookings + subq_3.metric_time__day + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -333,20 +333,20 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 + ) subq_3 WHERE metric_time__day > '2020-01-01' - ) subq_6 + ) subq_4 GROUP BY metric_time__day - ) subq_7 + ) subq_5 ON - subq_8.metric_time__day = subq_7.metric_time__day - ) subq_10 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_8 WHERE metric_time__day > '2020-01-01' - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_12 + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_10 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0_optimized.sql index 82130a57c7..aab114c3ea 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -11,15 +11,15 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_21.metric_time__day AS metric_time__day - , subq_20.bookings AS bookings + subq_17.metric_time__day AS metric_time__day + , subq_16.bookings AS bookings FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_22 + FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_21 + ) subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -36,17 +36,17 @@ FROM ( , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATETIME_TRUNC(ds, day) BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_18 + ) subq_14 WHERE metric_time__day > '2020-01-01' GROUP BY metric_time__day - ) subq_20 + ) subq_16 ON - subq_21.metric_time__day = subq_20.metric_time__day - ) subq_23 + subq_17.metric_time__day = subq_16.metric_time__day + ) subq_19 WHERE ( metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' ) AND ( metric_time__day > '2020-01-01' ) -) subq_25 +) subq_21 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0.sql index 94c9b710af..c0c6005913 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0.sql @@ -1,246 +1,246 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 + subq_10.metric_time__day + , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_11.metric_time__day - , subq_11.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_8.metric_time__day + , subq_8.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.bookings AS bookings FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - WHERE subq_9.ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_8 + subq_7.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_7 + WHERE subq_7.ds BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , SUM(subq_6.bookings) AS bookings + subq_4.metric_time__day + , SUM(subq_4.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.bookings + subq_3.metric_time__day + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -333,20 +333,20 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 + ) subq_3 WHERE metric_time__day > '2020-01-01' - ) subq_6 + ) subq_4 GROUP BY - subq_6.metric_time__day - ) subq_7 + subq_4.metric_time__day + ) subq_5 ON - subq_8.metric_time__day = subq_7.metric_time__day - ) subq_10 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_8 WHERE metric_time__day > '2020-01-01' - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_12 + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_10 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0_optimized.sql index 162e102a1f..db846ac1b4 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -11,15 +11,15 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_21.metric_time__day AS metric_time__day - , subq_20.bookings AS bookings + subq_17.metric_time__day AS metric_time__day + , subq_16.bookings AS bookings FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_22 + FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_21 + ) subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -36,17 +36,17 @@ FROM ( , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_18 + ) subq_14 WHERE metric_time__day > '2020-01-01' GROUP BY metric_time__day - ) subq_20 + ) subq_16 ON - subq_21.metric_time__day = subq_20.metric_time__day - ) subq_23 + subq_17.metric_time__day = subq_16.metric_time__day + ) subq_19 WHERE ( metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' ) AND ( metric_time__day > '2020-01-01' ) -) subq_25 +) subq_21 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0.sql index c8af0753e0..37494c04d8 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0.sql @@ -1,246 +1,246 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 + subq_10.metric_time__day + , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_11.metric_time__day - , subq_11.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_8.metric_time__day + , subq_8.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.bookings AS bookings FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - WHERE subq_9.ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_8 + subq_7.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_7 + WHERE subq_7.ds BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , SUM(subq_6.bookings) AS bookings + subq_4.metric_time__day + , SUM(subq_4.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.bookings + subq_3.metric_time__day + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -333,20 +333,20 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 + ) subq_3 WHERE metric_time__day > '2020-01-01' - ) subq_6 + ) subq_4 GROUP BY - subq_6.metric_time__day - ) subq_7 + subq_4.metric_time__day + ) subq_5 ON - subq_8.metric_time__day = subq_7.metric_time__day - ) subq_10 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_8 WHERE metric_time__day > '2020-01-01' - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_12 + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_10 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0_optimized.sql index 162e102a1f..db846ac1b4 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -11,15 +11,15 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_21.metric_time__day AS metric_time__day - , subq_20.bookings AS bookings + subq_17.metric_time__day AS metric_time__day + , subq_16.bookings AS bookings FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_22 + FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_21 + ) subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -36,17 +36,17 @@ FROM ( , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_18 + ) subq_14 WHERE metric_time__day > '2020-01-01' GROUP BY metric_time__day - ) subq_20 + ) subq_16 ON - subq_21.metric_time__day = subq_20.metric_time__day - ) subq_23 + subq_17.metric_time__day = subq_16.metric_time__day + ) subq_19 WHERE ( metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' ) AND ( metric_time__day > '2020-01-01' ) -) subq_25 +) subq_21 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0.sql index acf6b3b1d4..cf33f1752c 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0.sql @@ -1,246 +1,246 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 + subq_10.metric_time__day + , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_11.metric_time__day - , subq_11.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_8.metric_time__day + , subq_8.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.bookings AS bookings FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - WHERE subq_9.ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_8 + subq_7.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_7 + WHERE subq_7.ds BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , SUM(subq_6.bookings) AS bookings + subq_4.metric_time__day + , SUM(subq_4.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.bookings + subq_3.metric_time__day + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -333,20 +333,20 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 + ) subq_3 WHERE metric_time__day > '2020-01-01' - ) subq_6 + ) subq_4 GROUP BY - subq_6.metric_time__day - ) subq_7 + subq_4.metric_time__day + ) subq_5 ON - subq_8.metric_time__day = subq_7.metric_time__day - ) subq_10 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_8 WHERE metric_time__day > '2020-01-01' - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_12 + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_10 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0_optimized.sql index 162e102a1f..db846ac1b4 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -11,15 +11,15 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_21.metric_time__day AS metric_time__day - , subq_20.bookings AS bookings + subq_17.metric_time__day AS metric_time__day + , subq_16.bookings AS bookings FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_22 + FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_21 + ) subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -36,17 +36,17 @@ FROM ( , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_18 + ) subq_14 WHERE metric_time__day > '2020-01-01' GROUP BY metric_time__day - ) subq_20 + ) subq_16 ON - subq_21.metric_time__day = subq_20.metric_time__day - ) subq_23 + subq_17.metric_time__day = subq_16.metric_time__day + ) subq_19 WHERE ( metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' ) AND ( metric_time__day > '2020-01-01' ) -) subq_25 +) subq_21 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0.sql index d7dbea128c..457e76d661 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0.sql @@ -1,246 +1,246 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 + subq_10.metric_time__day + , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_11.metric_time__day - , subq_11.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_8.metric_time__day + , subq_8.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.bookings AS bookings FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - WHERE subq_9.ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_8 + subq_7.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_7 + WHERE subq_7.ds BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , SUM(subq_6.bookings) AS bookings + subq_4.metric_time__day + , SUM(subq_4.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.bookings + subq_3.metric_time__day + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -333,20 +333,20 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 + ) subq_3 WHERE metric_time__day > '2020-01-01' - ) subq_6 + ) subq_4 GROUP BY - subq_6.metric_time__day - ) subq_7 + subq_4.metric_time__day + ) subq_5 ON - subq_8.metric_time__day = subq_7.metric_time__day - ) subq_10 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_8 WHERE metric_time__day > '2020-01-01' - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_12 + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_10 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0_optimized.sql index 162e102a1f..db846ac1b4 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -11,15 +11,15 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_21.metric_time__day AS metric_time__day - , subq_20.bookings AS bookings + subq_17.metric_time__day AS metric_time__day + , subq_16.bookings AS bookings FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_22 + FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_21 + ) subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -36,17 +36,17 @@ FROM ( , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_18 + ) subq_14 WHERE metric_time__day > '2020-01-01' GROUP BY metric_time__day - ) subq_20 + ) subq_16 ON - subq_21.metric_time__day = subq_20.metric_time__day - ) subq_23 + subq_17.metric_time__day = subq_16.metric_time__day + ) subq_19 WHERE ( metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' ) AND ( metric_time__day > '2020-01-01' ) -) subq_25 +) subq_21 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0.sql index e9367be24f..5eb76738a5 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0.sql @@ -1,246 +1,246 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , COALESCE(subq_12.bookings, 0) AS bookings_fill_nulls_with_0 + subq_10.metric_time__day + , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_11.metric_time__day - , subq_11.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_8.metric_time__day + , subq_8.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.bookings AS bookings FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - WHERE subq_9.ds BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' - ) subq_8 + subq_7.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_7 + WHERE subq_7.ds BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , SUM(subq_6.bookings) AS bookings + subq_4.metric_time__day + , SUM(subq_4.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.bookings + subq_3.metric_time__day + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -333,20 +333,20 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' + ) subq_2 + ) subq_3 WHERE metric_time__day > '2020-01-01' - ) subq_6 + ) subq_4 GROUP BY - subq_6.metric_time__day - ) subq_7 + subq_4.metric_time__day + ) subq_5 ON - subq_8.metric_time__day = subq_7.metric_time__day - ) subq_10 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_8 WHERE metric_time__day > '2020-01-01' - ) subq_11 - WHERE subq_11.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' -) subq_12 + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' +) subq_10 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0_optimized.sql index 1e39c1c63f..32ec18030f 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -11,15 +11,15 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_21.metric_time__day AS metric_time__day - , subq_20.bookings AS bookings + subq_17.metric_time__day AS metric_time__day + , subq_16.bookings AS bookings FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_22 + FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' - ) subq_21 + ) subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -36,17 +36,17 @@ FROM ( , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' - ) subq_18 + ) subq_14 WHERE metric_time__day > '2020-01-01' GROUP BY metric_time__day - ) subq_20 + ) subq_16 ON - subq_21.metric_time__day = subq_20.metric_time__day - ) subq_23 + subq_17.metric_time__day = subq_16.metric_time__day + ) subq_19 WHERE ( metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' ) AND ( metric_time__day > '2020-01-01' ) -) subq_25 +) subq_21 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values_query_with_metric_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values_query_with_metric_filter__plan0.sql index 8a99c7037a..7076519bc5 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values_query_with_metric_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values_query_with_metric_filter__plan0.sql @@ -1,20 +1,20 @@ -- Pass Only Elements: ['listing',] SELECT - subq_12.listing + subq_8.listing FROM ( -- Constrain Output with WHERE SELECT - subq_11.listing - , subq_11.lux_listing - , subq_11.listing__lux_listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.lux_listing + , subq_7.listing__lux_listing + , subq_7.listing__bookings FROM ( -- Join Standard Outputs SELECT - subq_4.listing AS listing - , subq_4.lux_listing AS lux_listing - , subq_4.listing__lux_listing AS listing__lux_listing - , subq_10.listing__bookings AS listing__bookings + subq_0.listing AS listing + , subq_0.lux_listing AS lux_listing + , subq_0.listing__lux_listing AS listing__lux_listing + , subq_6.listing__bookings AS listing__bookings FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -22,128 +22,128 @@ FROM ( , lux_listing_mapping_src_28000.lux_listing_id AS lux_listing , lux_listing_mapping_src_28000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_28000 - ) subq_4 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_9.listing - , subq_9.listing__bookings + subq_5.listing + , subq_5.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.listing - , subq_8.bookings AS listing__bookings + subq_4.listing + , subq_4.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_7.listing - , SUM(subq_7.bookings) AS bookings + subq_3.listing + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_6.listing - , subq_6.bookings + subq_2.listing + , subq_2.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__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 + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -236,18 +236,18 @@ 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_5 - ) subq_6 - ) subq_7 + ) subq_1 + ) subq_2 + ) subq_3 GROUP BY listing - ) subq_8 - ) subq_9 - ) subq_10 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_4.listing = subq_10.listing - ) subq_11 + subq_0.listing = subq_6.listing + ) subq_7 WHERE listing__bookings > 2 -) subq_12 +) subq_8 GROUP BY listing diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values_query_with_metric_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values_query_with_metric_filter__plan0_optimized.sql index cde9c960c5..d79ef0aa09 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values_query_with_metric_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values_query_with_metric_filter__plan0_optimized.sql @@ -6,7 +6,7 @@ FROM ( -- Join Standard Outputs SELECT lux_listing_mapping_src_28000.listing_id AS listing - , subq_23.listing__bookings AS listing__bookings + , subq_15.listing__bookings AS listing__bookings FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_28000 FULL OUTER JOIN ( -- Aggregate Measures @@ -23,13 +23,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_20 + ) subq_12 GROUP BY listing - ) subq_23 + ) subq_15 ON - lux_listing_mapping_src_28000.listing_id = subq_23.listing -) subq_24 + lux_listing_mapping_src_28000.listing_id = subq_15.listing +) subq_16 WHERE listing__bookings > 2 GROUP BY listing diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql index cbaa9d4725..6e6328a698 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql @@ -1,136 +1,136 @@ -- Compute Metrics via Expressions SELECT - subq_17.bookers + subq_13.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_16.bookers) AS bookers + COUNT(DISTINCT subq_12.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_15.bookers + subq_11.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_14.guest__booking_value - , subq_14.bookers + subq_10.guest__booking_value + , subq_10.bookers FROM ( -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_13.guest__booking_value - , subq_13.bookers + subq_9.guest__booking_value + , subq_9.bookers FROM ( -- Join Standard Outputs SELECT - subq_6.guest AS guest - , subq_12.guest__booking_value AS guest__booking_value - , subq_6.bookers AS bookers + subq_2.guest AS guest + , subq_8.guest__booking_value AS guest__booking_value + , subq_2.bookers AS bookers FROM ( -- Pass Only Elements: ['bookers', 'guest'] SELECT - subq_5.guest - , subq_5.bookers + subq_1.guest + , subq_1.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -223,130 +223,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['guest', 'guest__booking_value'] SELECT - subq_11.guest - , subq_11.guest__booking_value + subq_7.guest + , subq_7.guest__booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.guest - , subq_10.booking_value AS guest__booking_value + subq_6.guest + , subq_6.booking_value AS guest__booking_value FROM ( -- Aggregate Measures SELECT - subq_9.guest - , SUM(subq_9.booking_value) AS booking_value + subq_5.guest + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'guest'] SELECT - subq_8.guest - , subq_8.booking_value + subq_4.guest + , subq_4.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -439,19 +439,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY guest - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.guest = subq_12.guest - ) subq_13 - ) subq_14 + subq_2.guest = subq_8.guest + ) subq_9 + ) subq_10 WHERE guest__booking_value > 1.00 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql index c689c65606..f0945b5733 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_30.guest__booking_value AS guest__booking_value - , subq_24.bookers AS bookers + subq_22.guest__booking_value AS guest__booking_value + , subq_16.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( guest_id AS guest , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY guest - ) subq_30 + ) subq_22 ON - subq_24.guest = subq_30.guest -) subq_32 + subq_16.guest = subq_22.guest +) subq_24 WHERE guest__booking_value > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0.sql index 388180cf2a..dd3e226c0c 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_39.listings + subq_24.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_38.listings) AS listings + SUM(subq_23.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_37.listings + subq_22.listings FROM ( -- Constrain Output with WHERE SELECT - subq_36.user__visit_buy_conversion_rate - , subq_36.listings + subq_21.user__visit_buy_conversion_rate + , subq_21.listings FROM ( -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - subq_35.user__visit_buy_conversion_rate - , subq_35.listings + subq_20.user__visit_buy_conversion_rate + , subq_20.listings FROM ( -- Join Standard Outputs SELECT - subq_17.user AS user - , subq_34.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate - , subq_17.listings AS listings + subq_2.user AS user + , subq_19.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_16.user - , subq_16.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,79 +160,79 @@ 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_15 - ) subq_16 - ) subq_17 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] SELECT - subq_33.user - , subq_33.user__visit_buy_conversion_rate + subq_18.user + , subq_18.user__visit_buy_conversion_rate FROM ( -- Compute Metrics via Expressions SELECT - subq_32.user - , CAST(subq_32.buys AS FLOAT64) / CAST(NULLIF(subq_32.visits, 0) AS FLOAT64) AS user__visit_buy_conversion_rate + subq_17.user + , CAST(subq_17.buys AS FLOAT64) / CAST(NULLIF(subq_17.visits, 0) AS FLOAT64) AS user__visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.user, subq_31.user) AS user - , MAX(subq_21.visits) AS visits - , MAX(subq_31.buys) AS buys + COALESCE(subq_6.user, subq_16.user) AS user + , MAX(subq_6.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_20.user - , SUM(subq_20.visits) AS visits + subq_5.user + , SUM(subq_5.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'user'] SELECT - subq_19.user - , subq_19.visits + subq_4.user + , subq_4.visits 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.visit__ds__day - , subq_18.visit__ds__week - , subq_18.visit__ds__month - , subq_18.visit__ds__quarter - , subq_18.visit__ds__year - , subq_18.visit__ds__extract_year - , subq_18.visit__ds__extract_quarter - , subq_18.visit__ds__extract_month - , subq_18.visit__ds__extract_day - , subq_18.visit__ds__extract_dow - , subq_18.visit__ds__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.user - , subq_18.session - , subq_18.visit__user - , subq_18.visit__session - , subq_18.referrer_id - , subq_18.visit__referrer_id - , subq_18.visits - , subq_18.visitors + 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.visit__ds__day + , subq_3.visit__ds__week + , subq_3.visit__ds__month + , subq_3.visit__ds__quarter + , subq_3.visit__ds__year + , subq_3.visit__ds__extract_year + , subq_3.visit__ds__extract_quarter + , subq_3.visit__ds__extract_month + , subq_3.visit__ds__extract_day + , subq_3.visit__ds__extract_dow + , subq_3.visit__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_3.user + , subq_3.session + , subq_3.visit__user + , subq_3.visit__session + , subq_3.referrer_id + , subq_3.visit__referrer_id + , subq_3.visits + , subq_3.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -267,108 +267,108 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_18 - ) subq_19 - ) subq_20 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY user - ) subq_21 + ) subq_6 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_30.user - , SUM(subq_30.buys) AS buys + subq_15.user + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'user'] SELECT - subq_29.user - , subq_29.buys + subq_14.user + , subq_14.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_28.ds__day - , subq_28.user - , subq_28.buys - , subq_28.visits + subq_13.ds__day + , subq_13.user + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_24.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_24.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_24.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_27.mf_internal_uuid AS mf_internal_uuid - , subq_27.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_23.ds__day - , subq_23.user - , subq_23.visits + subq_8.ds__day + , subq_8.user + , subq_8.visits 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.visit__ds__day - , subq_22.visit__ds__week - , subq_22.visit__ds__month - , subq_22.visit__ds__quarter - , subq_22.visit__ds__year - , subq_22.visit__ds__extract_year - , subq_22.visit__ds__extract_quarter - , subq_22.visit__ds__extract_month - , subq_22.visit__ds__extract_day - , subq_22.visit__ds__extract_dow - , subq_22.visit__ds__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.user - , subq_22.session - , subq_22.visit__user - , subq_22.visit__session - , subq_22.referrer_id - , subq_22.visit__referrer_id - , subq_22.visits - , subq_22.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -403,94 +403,94 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_22 - ) subq_23 - ) subq_24 + ) subq_7 + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_26.ds__day - , subq_26.ds__week - , subq_26.ds__month - , subq_26.ds__quarter - , subq_26.ds__year - , subq_26.ds__extract_year - , subq_26.ds__extract_quarter - , subq_26.ds__extract_month - , subq_26.ds__extract_day - , subq_26.ds__extract_dow - , subq_26.ds__extract_doy - , subq_26.buy__ds__day - , subq_26.buy__ds__week - , subq_26.buy__ds__month - , subq_26.buy__ds__quarter - , subq_26.buy__ds__year - , subq_26.buy__ds__extract_year - , subq_26.buy__ds__extract_quarter - , subq_26.buy__ds__extract_month - , subq_26.buy__ds__extract_day - , subq_26.buy__ds__extract_dow - , subq_26.buy__ds__extract_doy - , subq_26.metric_time__day - , subq_26.metric_time__week - , subq_26.metric_time__month - , subq_26.metric_time__quarter - , subq_26.metric_time__year - , subq_26.metric_time__extract_year - , subq_26.metric_time__extract_quarter - , subq_26.metric_time__extract_month - , subq_26.metric_time__extract_day - , subq_26.metric_time__extract_dow - , subq_26.metric_time__extract_doy - , subq_26.user - , subq_26.session_id - , subq_26.buy__user - , subq_26.buy__session_id - , subq_26.buys - , subq_26.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , GENERATE_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_25.ds__day - , subq_25.ds__week - , subq_25.ds__month - , subq_25.ds__quarter - , subq_25.ds__year - , subq_25.ds__extract_year - , subq_25.ds__extract_quarter - , subq_25.ds__extract_month - , subq_25.ds__extract_day - , subq_25.ds__extract_dow - , subq_25.ds__extract_doy - , subq_25.buy__ds__day - , subq_25.buy__ds__week - , subq_25.buy__ds__month - , subq_25.buy__ds__quarter - , subq_25.buy__ds__year - , subq_25.buy__ds__extract_year - , subq_25.buy__ds__extract_quarter - , subq_25.buy__ds__extract_month - , subq_25.buy__ds__extract_day - , subq_25.buy__ds__extract_dow - , subq_25.buy__ds__extract_doy - , subq_25.ds__day AS metric_time__day - , subq_25.ds__week AS metric_time__week - , subq_25.ds__month AS metric_time__month - , subq_25.ds__quarter AS metric_time__quarter - , subq_25.ds__year AS metric_time__year - , subq_25.ds__extract_year AS metric_time__extract_year - , subq_25.ds__extract_quarter AS metric_time__extract_quarter - , subq_25.ds__extract_month AS metric_time__extract_month - , subq_25.ds__extract_day AS metric_time__extract_day - , subq_25.ds__extract_dow AS metric_time__extract_dow - , subq_25.ds__extract_doy AS metric_time__extract_doy - , subq_25.user - , subq_25.session_id - , subq_25.buy__user - , subq_25.buy__session_id - , subq_25.buys - , subq_25.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -523,33 +523,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_25 - ) subq_26 - ) subq_27 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_24.user = subq_27.user + subq_9.user = subq_12.user ) AND ( - (subq_24.ds__day <= subq_27.ds__day) + (subq_9.ds__day <= subq_12.ds__day) ) - ) subq_28 - ) subq_29 - ) subq_30 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY user - ) subq_31 + ) subq_16 ON - subq_21.user = subq_31.user + subq_6.user = subq_16.user GROUP BY user - ) subq_32 - ) subq_33 - ) subq_34 + ) subq_17 + ) subq_18 + ) subq_19 ON - subq_17.user = subq_34.user - ) subq_35 - ) subq_36 + subq_2.user = subq_19.user + ) subq_20 + ) subq_21 WHERE user__visit_buy_conversion_rate > 2 - ) subq_37 - ) subq_38 -) subq_39 + ) subq_22 + ) subq_23 +) subq_24 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0_optimized.sql index cefdb0613e..2360c2bfc7 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - CAST(subq_72.buys AS FLOAT64) / CAST(NULLIF(subq_72.visits, 0) AS FLOAT64) AS user__visit_buy_conversion_rate - , subq_57.listings AS listings + CAST(subq_42.buys AS FLOAT64) / CAST(NULLIF(subq_42.visits, 0) AS FLOAT64) AS user__visit_buy_conversion_rate + , subq_27.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,17 +18,17 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_57 + ) subq_27 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_61.user, subq_71.user) AS user - , MAX(subq_61.visits) AS visits - , MAX(subq_71.buys) AS buys + COALESCE(subq_31.user, subq_41.user) AS user + , MAX(subq_31.visits) AS visits + , MAX(subq_41.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_60.user + subq_30.user , SUM(visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -38,46 +38,46 @@ FROM ( user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_60 + ) subq_30 GROUP BY user - ) subq_61 + ) subq_31 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'user'] -- Aggregate Measures SELECT - subq_68.user + subq_38.user , SUM(buys) AS buys FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_64.visits) OVER ( + first_value(subq_34.visits) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_64.ds__day) OVER ( + , first_value(subq_34.ds__day) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_64.user) OVER ( + , first_value(subq_34.user) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_67.mf_internal_uuid AS mf_internal_uuid - , subq_67.buys AS buys + , subq_37.mf_internal_uuid AS mf_internal_uuid + , subq_37.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -87,7 +87,7 @@ FROM ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_64 + ) subq_34 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -98,23 +98,23 @@ FROM ( , 1 AS buys , GENERATE_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_67 + ) subq_37 ON ( - subq_64.user = subq_67.user + subq_34.user = subq_37.user ) AND ( - (subq_64.ds__day <= subq_67.ds__day) + (subq_34.ds__day <= subq_37.ds__day) ) - ) subq_68 + ) subq_38 GROUP BY user - ) subq_71 + ) subq_41 ON - subq_61.user = subq_71.user + subq_31.user = subq_41.user GROUP BY user - ) subq_72 + ) subq_42 ON - subq_57.user = subq_72.user -) subq_76 + subq_27.user = subq_42.user +) subq_46 WHERE user__visit_buy_conversion_rate > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix__plan0.sql index 6dc29144e6..e57b6e40eb 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix__plan0.sql @@ -1,106 +1,106 @@ -- Compute Metrics via Expressions SELECT - subq_27.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_26.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_25.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_24.user__listing__user__average_booking_value - , subq_24.listings + subq_15.user__listing__user__average_booking_value + , subq_15.listings FROM ( -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_23.user__listing__user__average_booking_value - , subq_23.listings + subq_14.user__listing__user__average_booking_value + , subq_14.listings FROM ( -- Join Standard Outputs SELECT - subq_11.user AS user - , subq_22.listing__user AS user__listing__user - , subq_22.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_11.listings AS listings + subq_2.user AS user + , subq_13.listing__user AS user__listing__user + , subq_13.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_10.user - , subq_10.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__extract_quarter - , subq_9.ds__extract_month - , subq_9.ds__extract_day - , subq_9.ds__extract_dow - , subq_9.ds__extract_doy - , subq_9.created_at__day - , subq_9.created_at__week - , subq_9.created_at__month - , subq_9.created_at__quarter - , subq_9.created_at__year - , subq_9.created_at__extract_year - , subq_9.created_at__extract_quarter - , subq_9.created_at__extract_month - , subq_9.created_at__extract_day - , subq_9.created_at__extract_dow - , subq_9.created_at__extract_doy - , subq_9.listing__ds__day - , subq_9.listing__ds__week - , subq_9.listing__ds__month - , subq_9.listing__ds__quarter - , subq_9.listing__ds__year - , subq_9.listing__ds__extract_year - , subq_9.listing__ds__extract_quarter - , subq_9.listing__ds__extract_month - , subq_9.listing__ds__extract_day - , subq_9.listing__ds__extract_dow - , subq_9.listing__ds__extract_doy - , subq_9.listing__created_at__day - , subq_9.listing__created_at__week - , subq_9.listing__created_at__month - , subq_9.listing__created_at__quarter - , subq_9.listing__created_at__year - , subq_9.listing__created_at__extract_year - , subq_9.listing__created_at__extract_quarter - , subq_9.listing__created_at__extract_month - , subq_9.listing__created_at__extract_day - , subq_9.listing__created_at__extract_dow - , subq_9.listing__created_at__extract_doy - , subq_9.ds__day AS metric_time__day - , subq_9.ds__week AS metric_time__week - , subq_9.ds__month AS metric_time__month - , subq_9.ds__quarter AS metric_time__quarter - , subq_9.ds__year AS metric_time__year - , subq_9.ds__extract_year AS metric_time__extract_year - , subq_9.ds__extract_quarter AS metric_time__extract_quarter - , subq_9.ds__extract_month AS metric_time__extract_month - , subq_9.ds__extract_day AS metric_time__extract_day - , subq_9.ds__extract_dow AS metric_time__extract_dow - , subq_9.ds__extract_doy AS metric_time__extract_doy - , subq_9.listing - , subq_9.user - , subq_9.listing__user - , subq_9.country_latest - , subq_9.is_lux_latest - , subq_9.capacity_latest - , subq_9.listing__country_latest - , subq_9.listing__is_lux_latest - , subq_9.listing__capacity_latest - , subq_9.listings - , subq_9.largest_listing - , subq_9.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -161,141 +161,141 @@ 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_9 - ) subq_10 - ) subq_11 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] SELECT - subq_21.listing__user - , subq_21.listing__user__average_booking_value + subq_12.listing__user + , subq_12.listing__user__average_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_20.listing__user - , subq_20.average_booking_value AS listing__user__average_booking_value + subq_11.listing__user + , subq_11.average_booking_value AS listing__user__average_booking_value FROM ( -- Aggregate Measures SELECT - subq_19.listing__user - , AVG(subq_19.average_booking_value) AS average_booking_value + subq_10.listing__user + , AVG(subq_10.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__user'] SELECT - subq_18.listing__user - , subq_18.average_booking_value + subq_9.listing__user + , subq_9.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_14.listing AS listing - , subq_17.user AS listing__user - , subq_14.average_booking_value AS average_booking_value + subq_5.listing AS listing + , subq_8.user AS listing__user + , subq_5.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing'] SELECT - subq_13.listing - , subq_13.average_booking_value + subq_4.listing + , subq_4.average_booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -388,84 +388,84 @@ 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_12 - ) subq_13 - ) subq_14 + ) subq_3 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'user'] SELECT - subq_16.listing - , subq_16.user + subq_7.listing + , subq_7.user FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.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 @@ -526,23 +526,23 @@ 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_15 - ) subq_16 - ) subq_17 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_5.listing = subq_8.listing + ) subq_9 + ) subq_10 GROUP BY listing__user - ) subq_20 - ) subq_21 - ) subq_22 + ) subq_11 + ) subq_12 + ) subq_13 ON - subq_11.user = subq_22.listing__user - ) subq_23 - ) subq_24 + subq_2.user = subq_13.listing__user + ) subq_14 + ) subq_15 WHERE user__listing__user__average_booking_value > 1 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix__plan0_optimized.sql index adaafe3b4d..5494591133 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_50.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_39.listings AS listings + subq_32.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_21.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_39 + ) subq_21 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__user'] @@ -35,8 +35,8 @@ FROM ( bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY listing__user - ) subq_50 + ) subq_32 ON - subq_39.user = subq_50.listing__user -) subq_52 + subq_21.user = subq_32.listing__user +) subq_34 WHERE user__listing__user__average_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_multi_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_multi_hop__plan0.sql index c1ad0fe8a0..23c478367d 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_multi_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_multi_hop__plan0.sql @@ -1,76 +1,76 @@ -- Compute Metrics via Expressions SELECT - subq_40.third_hop_count + subq_22.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_39.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_21.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_38.third_hop_count + subq_20.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_37.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_37.third_hop_count + subq_19.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_19.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_36.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_36.third_hop_count + subq_18.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_18.third_hop_count FROM ( -- Join Standard Outputs SELECT - subq_20.customer_third_hop_id AS customer_third_hop_id - , subq_35.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id - , subq_35.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_20.third_hop_count AS third_hop_count + subq_2.customer_third_hop_id AS customer_third_hop_id + , subq_17.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_17.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_2.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_19.customer_third_hop_id - , subq_19.third_hop_count + subq_1.customer_third_hop_id + , subq_1.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - subq_18.third_hop_ds__day - , subq_18.third_hop_ds__week - , subq_18.third_hop_ds__month - , subq_18.third_hop_ds__quarter - , subq_18.third_hop_ds__year - , subq_18.third_hop_ds__extract_year - , subq_18.third_hop_ds__extract_quarter - , subq_18.third_hop_ds__extract_month - , subq_18.third_hop_ds__extract_day - , subq_18.third_hop_ds__extract_dow - , subq_18.third_hop_ds__extract_doy - , subq_18.customer_third_hop_id__third_hop_ds__day - , subq_18.customer_third_hop_id__third_hop_ds__week - , subq_18.customer_third_hop_id__third_hop_ds__month - , subq_18.customer_third_hop_id__third_hop_ds__quarter - , subq_18.customer_third_hop_id__third_hop_ds__year - , subq_18.customer_third_hop_id__third_hop_ds__extract_year - , subq_18.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_18.customer_third_hop_id__third_hop_ds__extract_month - , subq_18.customer_third_hop_id__third_hop_ds__extract_day - , subq_18.customer_third_hop_id__third_hop_ds__extract_dow - , subq_18.customer_third_hop_id__third_hop_ds__extract_doy - , subq_18.third_hop_ds__day AS metric_time__day - , subq_18.third_hop_ds__week AS metric_time__week - , subq_18.third_hop_ds__month AS metric_time__month - , subq_18.third_hop_ds__quarter AS metric_time__quarter - , subq_18.third_hop_ds__year AS metric_time__year - , subq_18.third_hop_ds__extract_year AS metric_time__extract_year - , subq_18.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_18.third_hop_ds__extract_month AS metric_time__extract_month - , subq_18.third_hop_ds__extract_day AS metric_time__extract_day - , subq_18.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_18.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_18.customer_third_hop_id - , subq_18.value - , subq_18.customer_third_hop_id__value - , subq_18.third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( -- Read Elements From Semantic Model 'third_hop_table' SELECT @@ -101,105 +101,105 @@ FROM ( , EXTRACT(dayofyear 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_18 - ) subq_19 - ) subq_20 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_34.account_id__customer_id__customer_third_hop_id - , subq_34.account_id__customer_id__customer_third_hop_id__txn_count + subq_16.account_id__customer_id__customer_third_hop_id + , subq_16.account_id__customer_id__customer_third_hop_id__txn_count FROM ( -- Compute Metrics via Expressions SELECT - subq_33.account_id__customer_id__customer_third_hop_id - , subq_33.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count + subq_15.account_id__customer_id__customer_third_hop_id + , subq_15.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count FROM ( -- Aggregate Measures SELECT - subq_32.account_id__customer_id__customer_third_hop_id - , SUM(subq_32.txn_count) AS txn_count + subq_14.account_id__customer_id__customer_third_hop_id + , SUM(subq_14.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] SELECT - subq_31.account_id__customer_id__customer_third_hop_id - , subq_31.txn_count + subq_13.account_id__customer_id__customer_third_hop_id + , subq_13.txn_count FROM ( -- Join Standard Outputs SELECT - subq_23.ds_partitioned__day AS ds_partitioned__day - , subq_30.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_23.account_id AS account_id - , subq_30.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id - , subq_23.txn_count AS txn_count + subq_5.ds_partitioned__day AS ds_partitioned__day + , subq_12.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_5.account_id AS account_id + , subq_12.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + , subq_5.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_22.ds_partitioned__day - , subq_22.account_id - , subq_22.txn_count + subq_4.ds_partitioned__day + , subq_4.account_id + , subq_4.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_21.ds_partitioned__day - , subq_21.ds_partitioned__week - , subq_21.ds_partitioned__month - , subq_21.ds_partitioned__quarter - , subq_21.ds_partitioned__year - , subq_21.ds_partitioned__extract_year - , subq_21.ds_partitioned__extract_quarter - , subq_21.ds_partitioned__extract_month - , subq_21.ds_partitioned__extract_day - , subq_21.ds_partitioned__extract_dow - , subq_21.ds_partitioned__extract_doy - , subq_21.ds__day - , subq_21.ds__week - , subq_21.ds__month - , subq_21.ds__quarter - , subq_21.ds__year - , subq_21.ds__extract_year - , subq_21.ds__extract_quarter - , subq_21.ds__extract_month - , subq_21.ds__extract_day - , subq_21.ds__extract_dow - , subq_21.ds__extract_doy - , subq_21.account_id__ds_partitioned__day - , subq_21.account_id__ds_partitioned__week - , subq_21.account_id__ds_partitioned__month - , subq_21.account_id__ds_partitioned__quarter - , subq_21.account_id__ds_partitioned__year - , subq_21.account_id__ds_partitioned__extract_year - , subq_21.account_id__ds_partitioned__extract_quarter - , subq_21.account_id__ds_partitioned__extract_month - , subq_21.account_id__ds_partitioned__extract_day - , subq_21.account_id__ds_partitioned__extract_dow - , subq_21.account_id__ds_partitioned__extract_doy - , subq_21.account_id__ds__day - , subq_21.account_id__ds__week - , subq_21.account_id__ds__month - , subq_21.account_id__ds__quarter - , subq_21.account_id__ds__year - , subq_21.account_id__ds__extract_year - , subq_21.account_id__ds__extract_quarter - , subq_21.account_id__ds__extract_month - , subq_21.account_id__ds__extract_day - , subq_21.account_id__ds__extract_dow - , subq_21.account_id__ds__extract_doy - , subq_21.ds__day AS metric_time__day - , subq_21.ds__week AS metric_time__week - , subq_21.ds__month AS metric_time__month - , subq_21.ds__quarter AS metric_time__quarter - , subq_21.ds__year AS metric_time__year - , subq_21.ds__extract_year AS metric_time__extract_year - , subq_21.ds__extract_quarter AS metric_time__extract_quarter - , subq_21.ds__extract_month AS metric_time__extract_month - , subq_21.ds__extract_day AS metric_time__extract_day - , subq_21.ds__extract_dow AS metric_time__extract_dow - , subq_21.ds__extract_doy AS metric_time__extract_doy - , subq_21.account_id - , subq_21.account_month - , subq_21.account_id__account_month - , subq_21.txn_count + 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.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.account_id__ds_partitioned__day + , subq_3.account_id__ds_partitioned__week + , subq_3.account_id__ds_partitioned__month + , subq_3.account_id__ds_partitioned__quarter + , subq_3.account_id__ds_partitioned__year + , subq_3.account_id__ds_partitioned__extract_year + , subq_3.account_id__ds_partitioned__extract_quarter + , subq_3.account_id__ds_partitioned__extract_month + , subq_3.account_id__ds_partitioned__extract_day + , subq_3.account_id__ds_partitioned__extract_dow + , subq_3.account_id__ds_partitioned__extract_doy + , subq_3.account_id__ds__day + , subq_3.account_id__ds__week + , subq_3.account_id__ds__month + , subq_3.account_id__ds__quarter + , subq_3.account_id__ds__year + , subq_3.account_id__ds__extract_year + , subq_3.account_id__ds__extract_quarter + , subq_3.account_id__ds__extract_month + , subq_3.account_id__ds__extract_day + , subq_3.account_id__ds__extract_dow + , subq_3.account_id__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_3.account_id + , subq_3.account_month + , subq_3.account_id__account_month + , subq_3.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -252,164 +252,164 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_3 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] SELECT - subq_29.ds_partitioned__day - , subq_29.account_id - , subq_29.customer_id__customer_third_hop_id + subq_11.ds_partitioned__day + , subq_11.account_id + , subq_11.customer_id__customer_third_hop_id FROM ( -- Join Standard Outputs SELECT - subq_25.ds_partitioned__day AS ds_partitioned__day - , subq_25.ds_partitioned__week AS ds_partitioned__week - , subq_25.ds_partitioned__month AS ds_partitioned__month - , subq_25.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_25.ds_partitioned__year AS ds_partitioned__year - , subq_25.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_25.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_25.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_25.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_25.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_25.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_25.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_25.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_25.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_25.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_25.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_25.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_25.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_25.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_25.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_25.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_25.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_25.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_25.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_25.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_25.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_25.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_25.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_25.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_25.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_25.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_25.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_25.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_25.metric_time__day AS metric_time__day - , subq_25.metric_time__week AS metric_time__week - , subq_25.metric_time__month AS metric_time__month - , subq_25.metric_time__quarter AS metric_time__quarter - , subq_25.metric_time__year AS metric_time__year - , subq_25.metric_time__extract_year AS metric_time__extract_year - , subq_25.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_25.metric_time__extract_month AS metric_time__extract_month - , subq_25.metric_time__extract_day AS metric_time__extract_day - , subq_25.metric_time__extract_dow AS metric_time__extract_dow - , subq_25.metric_time__extract_doy AS metric_time__extract_doy - , subq_28.acquired_ds__day AS customer_id__acquired_ds__day - , subq_28.acquired_ds__week AS customer_id__acquired_ds__week - , subq_28.acquired_ds__month AS customer_id__acquired_ds__month - , subq_28.acquired_ds__quarter AS customer_id__acquired_ds__quarter - , subq_28.acquired_ds__year AS customer_id__acquired_ds__year - , subq_28.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year - , subq_28.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter - , subq_28.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month - , subq_28.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day - , subq_28.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow - , subq_28.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy - , subq_28.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day - , subq_28.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week - , subq_28.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month - , subq_28.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter - , subq_28.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year - , subq_28.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year - , subq_28.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter - , subq_28.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month - , subq_28.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day - , subq_28.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow - , subq_28.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy - , subq_28.metric_time__day AS customer_id__metric_time__day - , subq_28.metric_time__week AS customer_id__metric_time__week - , subq_28.metric_time__month AS customer_id__metric_time__month - , subq_28.metric_time__quarter AS customer_id__metric_time__quarter - , subq_28.metric_time__year AS customer_id__metric_time__year - , subq_28.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_28.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_28.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_28.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_28.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_28.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_25.account_id AS account_id - , subq_25.customer_id AS customer_id - , subq_25.account_id__customer_id AS account_id__customer_id - , subq_25.bridge_account__account_id AS bridge_account__account_id - , subq_25.bridge_account__customer_id AS bridge_account__customer_id - , subq_28.customer_third_hop_id AS customer_id__customer_third_hop_id - , subq_28.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id - , subq_25.extra_dim AS extra_dim - , subq_25.account_id__extra_dim AS account_id__extra_dim - , subq_25.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_28.country AS customer_id__country - , subq_28.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country - , subq_25.account_customer_combos AS account_customer_combos + subq_7.ds_partitioned__day AS ds_partitioned__day + , subq_7.ds_partitioned__week AS ds_partitioned__week + , subq_7.ds_partitioned__month AS ds_partitioned__month + , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_7.ds_partitioned__year AS ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_7.metric_time__day AS metric_time__day + , subq_7.metric_time__week AS metric_time__week + , subq_7.metric_time__month AS metric_time__month + , subq_7.metric_time__quarter AS metric_time__quarter + , subq_7.metric_time__year AS metric_time__year + , subq_7.metric_time__extract_year AS metric_time__extract_year + , subq_7.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_7.metric_time__extract_month AS metric_time__extract_month + , subq_7.metric_time__extract_day AS metric_time__extract_day + , subq_7.metric_time__extract_dow AS metric_time__extract_dow + , subq_7.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.acquired_ds__day AS customer_id__acquired_ds__day + , subq_10.acquired_ds__week AS customer_id__acquired_ds__week + , subq_10.acquired_ds__month AS customer_id__acquired_ds__month + , subq_10.acquired_ds__quarter AS customer_id__acquired_ds__quarter + , subq_10.acquired_ds__year AS customer_id__acquired_ds__year + , subq_10.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year + , subq_10.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter + , subq_10.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month + , subq_10.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day + , subq_10.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow + , subq_10.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy + , subq_10.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day + , subq_10.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week + , subq_10.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month + , subq_10.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter + , subq_10.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year + , subq_10.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year + , subq_10.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter + , subq_10.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month + , subq_10.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day + , subq_10.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow + , subq_10.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy + , subq_10.metric_time__day AS customer_id__metric_time__day + , subq_10.metric_time__week AS customer_id__metric_time__week + , subq_10.metric_time__month AS customer_id__metric_time__month + , subq_10.metric_time__quarter AS customer_id__metric_time__quarter + , subq_10.metric_time__year AS customer_id__metric_time__year + , subq_10.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_10.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_10.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_10.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_10.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_10.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_7.account_id AS account_id + , subq_7.customer_id AS customer_id + , subq_7.account_id__customer_id AS account_id__customer_id + , subq_7.bridge_account__account_id AS bridge_account__account_id + , subq_7.bridge_account__customer_id AS bridge_account__customer_id + , subq_10.customer_third_hop_id AS customer_id__customer_third_hop_id + , subq_10.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id + , subq_7.extra_dim AS extra_dim + , subq_7.account_id__extra_dim AS account_id__extra_dim + , subq_7.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_10.country AS customer_id__country + , subq_10.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country + , subq_7.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.account_id__ds_partitioned__day - , subq_24.account_id__ds_partitioned__week - , subq_24.account_id__ds_partitioned__month - , subq_24.account_id__ds_partitioned__quarter - , subq_24.account_id__ds_partitioned__year - , subq_24.account_id__ds_partitioned__extract_year - , subq_24.account_id__ds_partitioned__extract_quarter - , subq_24.account_id__ds_partitioned__extract_month - , subq_24.account_id__ds_partitioned__extract_day - , subq_24.account_id__ds_partitioned__extract_dow - , subq_24.account_id__ds_partitioned__extract_doy - , subq_24.bridge_account__ds_partitioned__day - , subq_24.bridge_account__ds_partitioned__week - , subq_24.bridge_account__ds_partitioned__month - , subq_24.bridge_account__ds_partitioned__quarter - , subq_24.bridge_account__ds_partitioned__year - , subq_24.bridge_account__ds_partitioned__extract_year - , subq_24.bridge_account__ds_partitioned__extract_quarter - , subq_24.bridge_account__ds_partitioned__extract_month - , subq_24.bridge_account__ds_partitioned__extract_day - , subq_24.bridge_account__ds_partitioned__extract_dow - , subq_24.bridge_account__ds_partitioned__extract_doy - , subq_24.ds_partitioned__day AS metric_time__day - , subq_24.ds_partitioned__week AS metric_time__week - , subq_24.ds_partitioned__month AS metric_time__month - , subq_24.ds_partitioned__quarter AS metric_time__quarter - , subq_24.ds_partitioned__year AS metric_time__year - , subq_24.ds_partitioned__extract_year AS metric_time__extract_year - , subq_24.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_24.ds_partitioned__extract_month AS metric_time__extract_month - , subq_24.ds_partitioned__extract_day AS metric_time__extract_day - , subq_24.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_24.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_24.account_id - , subq_24.customer_id - , subq_24.account_id__customer_id - , subq_24.bridge_account__account_id - , subq_24.bridge_account__customer_id - , subq_24.extra_dim - , subq_24.account_id__extra_dim - , subq_24.bridge_account__extra_dim - , subq_24.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_6.account_id__ds_partitioned__week + , subq_6.account_id__ds_partitioned__month + , subq_6.account_id__ds_partitioned__quarter + , subq_6.account_id__ds_partitioned__year + , subq_6.account_id__ds_partitioned__extract_year + , subq_6.account_id__ds_partitioned__extract_quarter + , subq_6.account_id__ds_partitioned__extract_month + , subq_6.account_id__ds_partitioned__extract_day + , subq_6.account_id__ds_partitioned__extract_dow + , subq_6.account_id__ds_partitioned__extract_doy + , subq_6.bridge_account__ds_partitioned__day + , subq_6.bridge_account__ds_partitioned__week + , subq_6.bridge_account__ds_partitioned__month + , subq_6.bridge_account__ds_partitioned__quarter + , subq_6.bridge_account__ds_partitioned__year + , subq_6.bridge_account__ds_partitioned__extract_year + , subq_6.bridge_account__ds_partitioned__extract_quarter + , subq_6.bridge_account__ds_partitioned__extract_month + , subq_6.bridge_account__ds_partitioned__extract_day + , subq_6.bridge_account__ds_partitioned__extract_dow + , subq_6.bridge_account__ds_partitioned__extract_doy + , subq_6.ds_partitioned__day AS metric_time__day + , subq_6.ds_partitioned__week AS metric_time__week + , subq_6.ds_partitioned__month AS metric_time__month + , subq_6.ds_partitioned__quarter AS metric_time__quarter + , subq_6.ds_partitioned__year AS metric_time__year + , subq_6.ds_partitioned__extract_year AS metric_time__extract_year + , subq_6.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_6.ds_partitioned__extract_month AS metric_time__extract_month + , subq_6.ds_partitioned__extract_day AS metric_time__extract_day + , subq_6.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_6.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_6.account_id + , subq_6.customer_id + , subq_6.account_id__customer_id + , subq_6.bridge_account__account_id + , subq_6.bridge_account__customer_id + , subq_6.extra_dim + , subq_6.account_id__extra_dim + , subq_6.bridge_account__extra_dim + , subq_6.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -456,8 +456,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_24 - ) subq_25 + ) subq_6 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'country', @@ -513,112 +513,112 @@ FROM ( -- 'customer_third_hop_id__customer_id', -- ] SELECT - subq_27.acquired_ds__day - , subq_27.acquired_ds__week - , subq_27.acquired_ds__month - , subq_27.acquired_ds__quarter - , subq_27.acquired_ds__year - , subq_27.acquired_ds__extract_year - , subq_27.acquired_ds__extract_quarter - , subq_27.acquired_ds__extract_month - , subq_27.acquired_ds__extract_day - , subq_27.acquired_ds__extract_dow - , subq_27.acquired_ds__extract_doy - , subq_27.customer_id__acquired_ds__day - , subq_27.customer_id__acquired_ds__week - , subq_27.customer_id__acquired_ds__month - , subq_27.customer_id__acquired_ds__quarter - , subq_27.customer_id__acquired_ds__year - , subq_27.customer_id__acquired_ds__extract_year - , subq_27.customer_id__acquired_ds__extract_quarter - , subq_27.customer_id__acquired_ds__extract_month - , subq_27.customer_id__acquired_ds__extract_day - , subq_27.customer_id__acquired_ds__extract_dow - , subq_27.customer_id__acquired_ds__extract_doy - , subq_27.customer_third_hop_id__acquired_ds__day - , subq_27.customer_third_hop_id__acquired_ds__week - , subq_27.customer_third_hop_id__acquired_ds__month - , subq_27.customer_third_hop_id__acquired_ds__quarter - , subq_27.customer_third_hop_id__acquired_ds__year - , subq_27.customer_third_hop_id__acquired_ds__extract_year - , subq_27.customer_third_hop_id__acquired_ds__extract_quarter - , subq_27.customer_third_hop_id__acquired_ds__extract_month - , subq_27.customer_third_hop_id__acquired_ds__extract_day - , subq_27.customer_third_hop_id__acquired_ds__extract_dow - , subq_27.customer_third_hop_id__acquired_ds__extract_doy - , subq_27.metric_time__day - , subq_27.metric_time__week - , subq_27.metric_time__month - , subq_27.metric_time__quarter - , subq_27.metric_time__year - , subq_27.metric_time__extract_year - , subq_27.metric_time__extract_quarter - , subq_27.metric_time__extract_month - , subq_27.metric_time__extract_day - , subq_27.metric_time__extract_dow - , subq_27.metric_time__extract_doy - , subq_27.customer_id - , subq_27.customer_third_hop_id - , subq_27.customer_id__customer_third_hop_id - , subq_27.customer_third_hop_id__customer_id - , subq_27.country - , subq_27.customer_id__country - , subq_27.customer_third_hop_id__country + subq_9.acquired_ds__day + , subq_9.acquired_ds__week + , subq_9.acquired_ds__month + , subq_9.acquired_ds__quarter + , subq_9.acquired_ds__year + , subq_9.acquired_ds__extract_year + , subq_9.acquired_ds__extract_quarter + , subq_9.acquired_ds__extract_month + , subq_9.acquired_ds__extract_day + , subq_9.acquired_ds__extract_dow + , subq_9.acquired_ds__extract_doy + , subq_9.customer_id__acquired_ds__day + , subq_9.customer_id__acquired_ds__week + , subq_9.customer_id__acquired_ds__month + , subq_9.customer_id__acquired_ds__quarter + , subq_9.customer_id__acquired_ds__year + , subq_9.customer_id__acquired_ds__extract_year + , subq_9.customer_id__acquired_ds__extract_quarter + , subq_9.customer_id__acquired_ds__extract_month + , subq_9.customer_id__acquired_ds__extract_day + , subq_9.customer_id__acquired_ds__extract_dow + , subq_9.customer_id__acquired_ds__extract_doy + , subq_9.customer_third_hop_id__acquired_ds__day + , subq_9.customer_third_hop_id__acquired_ds__week + , subq_9.customer_third_hop_id__acquired_ds__month + , subq_9.customer_third_hop_id__acquired_ds__quarter + , subq_9.customer_third_hop_id__acquired_ds__year + , subq_9.customer_third_hop_id__acquired_ds__extract_year + , subq_9.customer_third_hop_id__acquired_ds__extract_quarter + , subq_9.customer_third_hop_id__acquired_ds__extract_month + , subq_9.customer_third_hop_id__acquired_ds__extract_day + , subq_9.customer_third_hop_id__acquired_ds__extract_dow + , subq_9.customer_third_hop_id__acquired_ds__extract_doy + , subq_9.metric_time__day + , subq_9.metric_time__week + , subq_9.metric_time__month + , subq_9.metric_time__quarter + , subq_9.metric_time__year + , subq_9.metric_time__extract_year + , subq_9.metric_time__extract_quarter + , subq_9.metric_time__extract_month + , subq_9.metric_time__extract_day + , subq_9.metric_time__extract_dow + , subq_9.metric_time__extract_doy + , subq_9.customer_id + , subq_9.customer_third_hop_id + , subq_9.customer_id__customer_third_hop_id + , subq_9.customer_third_hop_id__customer_id + , subq_9.country + , subq_9.customer_id__country + , subq_9.customer_third_hop_id__country FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - subq_26.acquired_ds__day - , subq_26.acquired_ds__week - , subq_26.acquired_ds__month - , subq_26.acquired_ds__quarter - , subq_26.acquired_ds__year - , subq_26.acquired_ds__extract_year - , subq_26.acquired_ds__extract_quarter - , subq_26.acquired_ds__extract_month - , subq_26.acquired_ds__extract_day - , subq_26.acquired_ds__extract_dow - , subq_26.acquired_ds__extract_doy - , subq_26.customer_id__acquired_ds__day - , subq_26.customer_id__acquired_ds__week - , subq_26.customer_id__acquired_ds__month - , subq_26.customer_id__acquired_ds__quarter - , subq_26.customer_id__acquired_ds__year - , subq_26.customer_id__acquired_ds__extract_year - , subq_26.customer_id__acquired_ds__extract_quarter - , subq_26.customer_id__acquired_ds__extract_month - , subq_26.customer_id__acquired_ds__extract_day - , subq_26.customer_id__acquired_ds__extract_dow - , subq_26.customer_id__acquired_ds__extract_doy - , subq_26.customer_third_hop_id__acquired_ds__day - , subq_26.customer_third_hop_id__acquired_ds__week - , subq_26.customer_third_hop_id__acquired_ds__month - , subq_26.customer_third_hop_id__acquired_ds__quarter - , subq_26.customer_third_hop_id__acquired_ds__year - , subq_26.customer_third_hop_id__acquired_ds__extract_year - , subq_26.customer_third_hop_id__acquired_ds__extract_quarter - , subq_26.customer_third_hop_id__acquired_ds__extract_month - , subq_26.customer_third_hop_id__acquired_ds__extract_day - , subq_26.customer_third_hop_id__acquired_ds__extract_dow - , subq_26.customer_third_hop_id__acquired_ds__extract_doy - , subq_26.acquired_ds__day AS metric_time__day - , subq_26.acquired_ds__week AS metric_time__week - , subq_26.acquired_ds__month AS metric_time__month - , subq_26.acquired_ds__quarter AS metric_time__quarter - , subq_26.acquired_ds__year AS metric_time__year - , subq_26.acquired_ds__extract_year AS metric_time__extract_year - , subq_26.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_26.acquired_ds__extract_month AS metric_time__extract_month - , subq_26.acquired_ds__extract_day AS metric_time__extract_day - , subq_26.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_26.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_26.customer_id - , subq_26.customer_third_hop_id - , subq_26.customer_id__customer_third_hop_id - , subq_26.customer_third_hop_id__customer_id - , subq_26.country - , subq_26.customer_id__country - , subq_26.customer_third_hop_id__country - , subq_26.customers_with_other_data + subq_8.acquired_ds__day + , subq_8.acquired_ds__week + , subq_8.acquired_ds__month + , subq_8.acquired_ds__quarter + , subq_8.acquired_ds__year + , subq_8.acquired_ds__extract_year + , subq_8.acquired_ds__extract_quarter + , subq_8.acquired_ds__extract_month + , subq_8.acquired_ds__extract_day + , subq_8.acquired_ds__extract_dow + , subq_8.acquired_ds__extract_doy + , subq_8.customer_id__acquired_ds__day + , subq_8.customer_id__acquired_ds__week + , subq_8.customer_id__acquired_ds__month + , subq_8.customer_id__acquired_ds__quarter + , subq_8.customer_id__acquired_ds__year + , subq_8.customer_id__acquired_ds__extract_year + , subq_8.customer_id__acquired_ds__extract_quarter + , subq_8.customer_id__acquired_ds__extract_month + , subq_8.customer_id__acquired_ds__extract_day + , subq_8.customer_id__acquired_ds__extract_dow + , subq_8.customer_id__acquired_ds__extract_doy + , subq_8.customer_third_hop_id__acquired_ds__day + , subq_8.customer_third_hop_id__acquired_ds__week + , subq_8.customer_third_hop_id__acquired_ds__month + , subq_8.customer_third_hop_id__acquired_ds__quarter + , subq_8.customer_third_hop_id__acquired_ds__year + , subq_8.customer_third_hop_id__acquired_ds__extract_year + , subq_8.customer_third_hop_id__acquired_ds__extract_quarter + , subq_8.customer_third_hop_id__acquired_ds__extract_month + , subq_8.customer_third_hop_id__acquired_ds__extract_day + , subq_8.customer_third_hop_id__acquired_ds__extract_dow + , subq_8.customer_third_hop_id__acquired_ds__extract_doy + , subq_8.acquired_ds__day AS metric_time__day + , subq_8.acquired_ds__week AS metric_time__week + , subq_8.acquired_ds__month AS metric_time__month + , subq_8.acquired_ds__quarter AS metric_time__quarter + , subq_8.acquired_ds__year AS metric_time__year + , subq_8.acquired_ds__extract_year AS metric_time__extract_year + , subq_8.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_8.acquired_ds__extract_month AS metric_time__extract_month + , subq_8.acquired_ds__extract_day AS metric_time__extract_day + , subq_8.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_8.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_8.customer_id + , subq_8.customer_third_hop_id + , subq_8.customer_id__customer_third_hop_id + , subq_8.customer_third_hop_id__customer_id + , subq_8.country + , subq_8.customer_id__country + , subq_8.customer_third_hop_id__country + , subq_8.customers_with_other_data FROM ( -- Read Elements From Semantic Model 'customer_other_data' SELECT @@ -664,31 +664,31 @@ 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_26 - ) subq_27 - ) subq_28 + ) subq_8 + ) subq_9 + ) subq_10 ON - subq_25.customer_id = subq_28.customer_id - ) subq_29 - ) subq_30 + subq_7.customer_id = subq_10.customer_id + ) subq_11 + ) subq_12 ON ( - subq_23.account_id = subq_30.account_id + subq_5.account_id = subq_12.account_id ) AND ( - subq_23.ds_partitioned__day = subq_30.ds_partitioned__day + subq_5.ds_partitioned__day = subq_12.ds_partitioned__day ) - ) subq_31 - ) subq_32 + ) subq_13 + ) subq_14 GROUP BY account_id__customer_id__customer_third_hop_id - ) subq_33 - ) subq_34 - ) subq_35 + ) subq_15 + ) subq_16 + ) subq_17 ON - subq_20.customer_third_hop_id = subq_35.account_id__customer_id__customer_third_hop_id - ) subq_36 - ) subq_37 + subq_2.customer_third_hop_id = subq_17.account_id__customer_id__customer_third_hop_id + ) subq_18 + ) subq_19 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 - ) subq_38 - ) subq_39 -) subq_40 + ) subq_20 + ) subq_21 +) subq_22 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_multi_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_multi_hop__plan0_optimized.sql index 77215c6982..60ede6bbce 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_multi_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_multi_hop__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_76.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + subq_40.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count , 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 ( @@ -18,7 +18,7 @@ FROM ( -- Compute Metrics via Expressions -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_71.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + subq_35.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id , SUM(account_month_txns_src_22000.txn_count) AS account_id__customer_id__customer_third_hop_id__txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -33,17 +33,17 @@ FROM ( ***************************.customer_other_data customer_other_data_src_22000 ON bridge_table_src_22000.customer_id = customer_other_data_src_22000.customer_id - ) subq_71 + ) subq_35 ON ( - account_month_txns_src_22000.account_id = subq_71.account_id + account_month_txns_src_22000.account_id = subq_35.account_id ) AND ( - DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, day) = subq_71.ds_partitioned__day + DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, day) = subq_35.ds_partitioned__day ) GROUP BY account_id__customer_id__customer_third_hop_id - ) subq_76 + ) subq_40 ON - third_hop_table_src_22000.customer_third_hop_id = subq_76.account_id__customer_id__customer_third_hop_id -) subq_78 + third_hop_table_src_22000.customer_third_hop_id = subq_40.account_id__customer_id__customer_third_hop_id +) subq_42 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_single_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_single_hop__plan0.sql index 55f1ad847b..8890da357f 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_single_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_single_hop__plan0.sql @@ -1,76 +1,76 @@ -- Compute Metrics via Expressions SELECT - subq_25.third_hop_count + subq_16.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_24.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_15.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_23.third_hop_count + subq_14.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_22.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_22.third_hop_count + subq_13.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_13.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_21.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_21.third_hop_count + subq_12.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_12.third_hop_count FROM ( -- Join Standard Outputs SELECT - 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 + subq_2.customer_third_hop_id AS customer_third_hop_id + , subq_11.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_11.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_2.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_10.customer_third_hop_id - , subq_10.third_hop_count + subq_1.customer_third_hop_id + , subq_1.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - 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 + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( -- Read Elements From Semantic Model 'third_hop_table' SELECT @@ -101,151 +101,151 @@ FROM ( , EXTRACT(dayofyear 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_9 - ) subq_10 - ) subq_11 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_19.customer_id__customer_third_hop_id - , subq_19.customer_id__customer_third_hop_id__paraguayan_customers + subq_10.customer_id__customer_third_hop_id + , subq_10.customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Compute Metrics via Expressions SELECT - subq_18.customer_id__customer_third_hop_id - , subq_18.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_9.customer_id__customer_third_hop_id + , subq_9.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Aggregate Measures SELECT - subq_17.customer_id__customer_third_hop_id - , SUM(subq_17.customers_with_other_data) AS customers_with_other_data + subq_8.customer_id__customer_third_hop_id + , SUM(subq_8.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_16.customer_id__customer_third_hop_id - , subq_16.customers_with_other_data + subq_7.customer_id__customer_third_hop_id + , subq_7.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_15.customer_id__customer_third_hop_id - , subq_15.customer_id__country - , subq_15.customers_with_other_data + subq_6.customer_id__customer_third_hop_id + , subq_6.customer_id__country + , subq_6.customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT - subq_14.customer_id__customer_third_hop_id - , subq_14.customer_id__country - , subq_14.customers_with_other_data + subq_5.customer_id__customer_third_hop_id + , subq_5.customer_id__country + , subq_5.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - 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 + subq_4.acquired_ds__day + , subq_4.acquired_ds__week + , subq_4.acquired_ds__month + , subq_4.acquired_ds__quarter + , subq_4.acquired_ds__year + , subq_4.acquired_ds__extract_year + , subq_4.acquired_ds__extract_quarter + , subq_4.acquired_ds__extract_month + , subq_4.acquired_ds__extract_day + , subq_4.acquired_ds__extract_dow + , subq_4.acquired_ds__extract_doy + , subq_4.customer_id__acquired_ds__day + , subq_4.customer_id__acquired_ds__week + , subq_4.customer_id__acquired_ds__month + , subq_4.customer_id__acquired_ds__quarter + , subq_4.customer_id__acquired_ds__year + , subq_4.customer_id__acquired_ds__extract_year + , subq_4.customer_id__acquired_ds__extract_quarter + , subq_4.customer_id__acquired_ds__extract_month + , subq_4.customer_id__acquired_ds__extract_day + , subq_4.customer_id__acquired_ds__extract_dow + , subq_4.customer_id__acquired_ds__extract_doy + , subq_4.customer_third_hop_id__acquired_ds__day + , subq_4.customer_third_hop_id__acquired_ds__week + , subq_4.customer_third_hop_id__acquired_ds__month + , subq_4.customer_third_hop_id__acquired_ds__quarter + , subq_4.customer_third_hop_id__acquired_ds__year + , subq_4.customer_third_hop_id__acquired_ds__extract_year + , subq_4.customer_third_hop_id__acquired_ds__extract_quarter + , subq_4.customer_third_hop_id__acquired_ds__extract_month + , subq_4.customer_third_hop_id__acquired_ds__extract_day + , subq_4.customer_third_hop_id__acquired_ds__extract_dow + , subq_4.customer_third_hop_id__acquired_ds__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.customer_id + , subq_4.customer_third_hop_id + , subq_4.customer_id__customer_third_hop_id + , subq_4.customer_third_hop_id__customer_id + , subq_4.country + , subq_4.customer_id__country + , subq_4.customer_third_hop_id__country + , subq_4.customers_with_other_data FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - 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 + subq_3.acquired_ds__day + , subq_3.acquired_ds__week + , subq_3.acquired_ds__month + , subq_3.acquired_ds__quarter + , subq_3.acquired_ds__year + , subq_3.acquired_ds__extract_year + , subq_3.acquired_ds__extract_quarter + , subq_3.acquired_ds__extract_month + , subq_3.acquired_ds__extract_day + , subq_3.acquired_ds__extract_dow + , subq_3.acquired_ds__extract_doy + , subq_3.customer_id__acquired_ds__day + , subq_3.customer_id__acquired_ds__week + , subq_3.customer_id__acquired_ds__month + , subq_3.customer_id__acquired_ds__quarter + , subq_3.customer_id__acquired_ds__year + , subq_3.customer_id__acquired_ds__extract_year + , subq_3.customer_id__acquired_ds__extract_quarter + , subq_3.customer_id__acquired_ds__extract_month + , subq_3.customer_id__acquired_ds__extract_day + , subq_3.customer_id__acquired_ds__extract_dow + , subq_3.customer_id__acquired_ds__extract_doy + , subq_3.customer_third_hop_id__acquired_ds__day + , subq_3.customer_third_hop_id__acquired_ds__week + , subq_3.customer_third_hop_id__acquired_ds__month + , subq_3.customer_third_hop_id__acquired_ds__quarter + , subq_3.customer_third_hop_id__acquired_ds__year + , subq_3.customer_third_hop_id__acquired_ds__extract_year + , subq_3.customer_third_hop_id__acquired_ds__extract_quarter + , subq_3.customer_third_hop_id__acquired_ds__extract_month + , subq_3.customer_third_hop_id__acquired_ds__extract_day + , subq_3.customer_third_hop_id__acquired_ds__extract_dow + , subq_3.customer_third_hop_id__acquired_ds__extract_doy + , subq_3.acquired_ds__day AS metric_time__day + , subq_3.acquired_ds__week AS metric_time__week + , subq_3.acquired_ds__month AS metric_time__month + , subq_3.acquired_ds__quarter AS metric_time__quarter + , subq_3.acquired_ds__year AS metric_time__year + , subq_3.acquired_ds__extract_year AS metric_time__extract_year + , subq_3.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_3.acquired_ds__extract_month AS metric_time__extract_month + , subq_3.acquired_ds__extract_day AS metric_time__extract_day + , subq_3.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_3.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_3.customer_id + , subq_3.customer_third_hop_id + , subq_3.customer_id__customer_third_hop_id + , subq_3.customer_third_hop_id__customer_id + , subq_3.country + , subq_3.customer_id__country + , subq_3.customer_third_hop_id__country + , subq_3.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_12 - ) subq_13 + ) subq_3 + ) subq_4 WHERE customer_id__country = 'paraguay' - ) subq_14 - ) subq_15 + ) subq_5 + ) subq_6 WHERE customer_id__country = 'paraguay' - ) subq_16 - ) subq_17 + ) subq_7 + ) subq_8 GROUP BY customer_id__customer_third_hop_id - ) subq_18 - ) subq_19 - ) subq_20 + ) subq_9 + ) subq_10 + ) subq_11 ON - subq_11.customer_third_hop_id = subq_20.customer_id__customer_third_hop_id - ) subq_21 - ) subq_22 + subq_2.customer_third_hop_id = subq_11.customer_id__customer_third_hop_id + ) subq_12 + ) subq_13 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_23 - ) subq_24 -) subq_25 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_single_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_single_hop__plan0_optimized.sql index 0fd2bf1820..b73c99c9a9 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_single_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/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_46.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_28.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_39 + ) subq_21 WHERE customer_id__country = 'paraguay' - ) subq_41 + ) subq_23 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_46 + ) subq_28 ON - third_hop_table_src_22000.customer_third_hop_id = subq_46.customer_id__customer_third_hop_id -) subq_48 + third_hop_table_src_22000.customer_third_hop_id = subq_28.customer_id__customer_third_hop_id +) subq_30 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_filtered_by_itself__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_filtered_by_itself__plan0.sql index dc6e302472..81433f10c2 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_filtered_by_itself__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_filtered_by_itself__plan0.sql @@ -1,136 +1,136 @@ -- Compute Metrics via Expressions SELECT - subq_17.bookers + subq_13.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_16.bookers) AS bookers + COUNT(DISTINCT subq_12.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_15.bookers + subq_11.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_14.listing__bookers - , subq_14.bookers + subq_10.listing__bookers + , subq_10.bookers FROM ( -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_13.listing__bookers - , subq_13.bookers + subq_9.listing__bookers + , subq_9.bookers FROM ( -- Join Standard Outputs SELECT - subq_6.listing AS listing - , subq_12.listing__bookers AS listing__bookers - , subq_6.bookers AS bookers + subq_2.listing AS listing + , subq_8.listing__bookers AS listing__bookers + , subq_2.bookers AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_5.listing - , subq_5.bookers + subq_1.listing + , subq_1.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -223,130 +223,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookers'] SELECT - subq_11.listing - , subq_11.listing__bookers + subq_7.listing + , subq_7.listing__bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookers AS listing__bookers + subq_6.listing + , subq_6.bookers AS listing__bookers FROM ( -- Aggregate Measures SELECT - subq_9.listing - , COUNT(DISTINCT subq_9.bookers) AS bookers + subq_5.listing + , COUNT(DISTINCT subq_5.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_8.listing - , subq_8.bookers + subq_4.listing + , subq_4.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -439,19 +439,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY listing - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookers > 1.00 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_filtered_by_itself__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_filtered_by_itself__plan0_optimized.sql index 538e44b0b9..171d08c509 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_filtered_by_itself__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_filtered_by_itself__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_30.listing__bookers AS listing__bookers - , subq_24.bookers AS bookers + subq_22.listing__bookers AS listing__bookers + , subq_16.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookers > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_metric_in_where_filter__plan0.sql index ee56995360..2341f5bd11 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_metric_in_where_filter__plan0.sql @@ -1,112 +1,112 @@ -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day - , subq_17.listings AS active_listings + subq_13.metric_time__day + , subq_13.listings AS active_listings FROM ( -- Aggregate Measures SELECT - subq_16.metric_time__day - , SUM(subq_16.listings) AS listings + subq_12.metric_time__day + , SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day'] SELECT - subq_15.metric_time__day - , subq_15.listings + subq_11.metric_time__day + , subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.metric_time__day - , subq_14.listing__bookings - , subq_14.listings + subq_10.metric_time__day + , subq_10.listing__bookings + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_13.metric_time__day - , subq_13.listing__bookings - , subq_13.listings + subq_9.metric_time__day + , subq_9.listing__bookings + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.metric_time__day AS metric_time__day - , subq_6.listing AS listing - , subq_12.listing__bookings AS listing__bookings - , subq_6.listings AS listings + subq_2.metric_time__day AS metric_time__day + , subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] SELECT - subq_5.metric_time__day - , subq_5.listing - , subq_5.listings + subq_1.metric_time__day + , subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -167,130 +167,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_11.listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing - , SUM(subq_9.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_8.listing - , subq_8.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -383,21 +383,21 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY listing - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookings > 2 - ) subq_15 - ) subq_16 + ) subq_11 + ) subq_12 GROUP BY metric_time__day -) subq_17 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_metric_in_where_filter__plan0_optimized.sql index 51a87c89af..d74b9ae977 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_metric_in_where_filter__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_24.metric_time__day AS metric_time__day - , subq_30.listing__bookings AS listing__bookings - , subq_24.listings AS listings + subq_16.metric_time__day AS metric_time__day + , subq_22.listing__bookings AS listing__bookings + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -21,7 +21,7 @@ FROM ( , listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -37,13 +37,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_27 + ) subq_19 GROUP BY listing - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookings > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_cumulative_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_cumulative_metric_in_where_filter__plan0.sql index ca7f8d244e..5794f57594 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_cumulative_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_cumulative_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_17.listings + subq_13.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_16.listings) AS listings + SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_15.listings + subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.user__revenue_all_time - , subq_14.listings + subq_10.user__revenue_all_time + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_13.user__revenue_all_time - , subq_13.listings + subq_9.user__revenue_all_time + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.user AS user - , subq_12.user__revenue_all_time AS user__revenue_all_time - , subq_6.listings AS listings + subq_2.user AS user + , subq_8.user__revenue_all_time AS user__revenue_all_time + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_5.user - , subq_5.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,68 +160,68 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user', 'user__revenue_all_time'] SELECT - subq_11.user - , subq_11.user__revenue_all_time + subq_7.user + , subq_7.user__revenue_all_time FROM ( -- Compute Metrics via Expressions SELECT - subq_10.user - , subq_10.txn_revenue AS user__revenue_all_time + subq_6.user + , subq_6.txn_revenue AS user__revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_9.user - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_5.user + , SUM(subq_5.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'user'] SELECT - subq_8.user - , subq_8.txn_revenue + subq_4.user + , subq_4.txn_revenue FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.revenue_instance__ds__day - , subq_7.revenue_instance__ds__week - , subq_7.revenue_instance__ds__month - , subq_7.revenue_instance__ds__quarter - , subq_7.revenue_instance__ds__year - , subq_7.revenue_instance__ds__extract_year - , subq_7.revenue_instance__ds__extract_quarter - , subq_7.revenue_instance__ds__extract_month - , subq_7.revenue_instance__ds__extract_day - , subq_7.revenue_instance__ds__extract_dow - , subq_7.revenue_instance__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.revenue_instance__user - , subq_7.txn_revenue + 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.revenue_instance__ds__day + , subq_3.revenue_instance__ds__week + , subq_3.revenue_instance__ds__month + , subq_3.revenue_instance__ds__quarter + , subq_3.revenue_instance__ds__year + , subq_3.revenue_instance__ds__extract_year + , subq_3.revenue_instance__ds__extract_quarter + , subq_3.revenue_instance__ds__extract_month + , subq_3.revenue_instance__ds__extract_day + , subq_3.revenue_instance__ds__extract_dow + , subq_3.revenue_instance__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_3.user + , subq_3.revenue_instance__user + , subq_3.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -251,19 +251,19 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY user - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.user = subq_12.user - ) subq_13 - ) subq_14 + subq_2.user = subq_8.user + ) subq_9 + ) subq_10 WHERE user__revenue_all_time > 1 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql index fc4df3fefd..aa49927a1c 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_30.user__revenue_all_time AS user__revenue_all_time - , subq_24.listings AS listings + subq_22.user__revenue_all_time AS user__revenue_all_time + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_revenue revenue_src_28000 GROUP BY user - ) subq_30 + ) subq_22 ON - subq_24.user = subq_30.user -) subq_32 + subq_16.user = subq_22.user +) subq_24 WHERE user__revenue_all_time > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_derived_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_derived_metric_in_where_filter__plan0.sql index 08af12418e..92c1f08572 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_derived_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_derived_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_31.listings + subq_20.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_30.listings) AS listings + SUM(subq_19.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_29.listings + subq_18.listings FROM ( -- Constrain Output with WHERE SELECT - subq_28.listing__views_times_booking_value - , subq_28.listings + subq_17.listing__views_times_booking_value + , subq_17.listings FROM ( -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_27.listing__views_times_booking_value - , subq_27.listings + subq_16.listing__views_times_booking_value + , subq_16.listings FROM ( -- Join Standard Outputs SELECT - subq_13.listing AS listing - , subq_26.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_13.listings AS listings + subq_2.listing AS listing + , subq_15.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_12.listing - , subq_12.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,141 +160,141 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] SELECT - subq_25.listing - , subq_25.listing__views_times_booking_value + subq_14.listing + , subq_14.listing__views_times_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_24.listing + subq_13.listing , booking_value * views AS listing__views_times_booking_value FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.listing, subq_23.listing) AS listing - , MAX(subq_18.booking_value) AS booking_value - , MAX(subq_23.views) AS views + COALESCE(subq_7.listing, subq_12.listing) AS listing + , MAX(subq_7.booking_value) AS booking_value + , MAX(subq_12.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_17.listing - , subq_17.booking_value + subq_6.listing + , subq_6.booking_value FROM ( -- Aggregate Measures SELECT - subq_16.listing - , SUM(subq_16.booking_value) AS booking_value + subq_5.listing + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'listing'] SELECT - subq_15.listing - , subq_15.booking_value + subq_4.listing + , subq_4.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_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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -387,91 +387,91 @@ 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_3 + ) subq_4 + ) subq_5 GROUP BY listing - ) subq_17 - ) subq_18 + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.listing - , subq_22.views + subq_11.listing + , subq_11.views FROM ( -- Aggregate Measures SELECT - subq_21.listing - , SUM(subq_21.views) AS views + subq_10.listing + , SUM(subq_10.views) AS views FROM ( -- Pass Only Elements: ['views', 'listing'] SELECT - subq_20.listing - , subq_20.views + subq_9.listing + , subq_9.views FROM ( -- Metric Time Dimension 'ds' 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.view__ds__day - , subq_19.view__ds__week - , subq_19.view__ds__month - , subq_19.view__ds__quarter - , subq_19.view__ds__year - , subq_19.view__ds__extract_year - , subq_19.view__ds__extract_quarter - , subq_19.view__ds__extract_month - , subq_19.view__ds__extract_day - , subq_19.view__ds__extract_dow - , subq_19.view__ds__extract_doy - , subq_19.view__ds_partitioned__day - , subq_19.view__ds_partitioned__week - , subq_19.view__ds_partitioned__month - , subq_19.view__ds_partitioned__quarter - , subq_19.view__ds_partitioned__year - , subq_19.view__ds_partitioned__extract_year - , subq_19.view__ds_partitioned__extract_quarter - , subq_19.view__ds_partitioned__extract_month - , subq_19.view__ds_partitioned__extract_day - , subq_19.view__ds_partitioned__extract_dow - , subq_19.view__ds_partitioned__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.user - , subq_19.view__listing - , subq_19.view__user - , subq_19.views + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.view__ds__day + , subq_8.view__ds__week + , subq_8.view__ds__month + , subq_8.view__ds__quarter + , subq_8.view__ds__year + , subq_8.view__ds__extract_year + , subq_8.view__ds__extract_quarter + , subq_8.view__ds__extract_month + , subq_8.view__ds__extract_day + , subq_8.view__ds__extract_dow + , subq_8.view__ds__extract_doy + , subq_8.view__ds_partitioned__day + , subq_8.view__ds_partitioned__week + , subq_8.view__ds_partitioned__month + , subq_8.view__ds_partitioned__quarter + , subq_8.view__ds_partitioned__year + , subq_8.view__ds_partitioned__extract_year + , subq_8.view__ds_partitioned__extract_quarter + , subq_8.view__ds_partitioned__extract_month + , subq_8.view__ds_partitioned__extract_day + , subq_8.view__ds_partitioned__extract_dow + , subq_8.view__ds_partitioned__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.user + , subq_8.view__listing + , subq_8.view__user + , subq_8.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT @@ -525,25 +525,25 @@ FROM ( , views_source_src_28000.listing_id AS view__listing , views_source_src_28000.user_id AS view__user FROM ***************************.fct_views views_source_src_28000 - ) subq_19 - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY listing - ) subq_22 - ) subq_23 + ) subq_11 + ) subq_12 ON - subq_18.listing = subq_23.listing + subq_7.listing = subq_12.listing GROUP BY listing - ) subq_24 - ) subq_25 - ) subq_26 + ) subq_13 + ) subq_14 + ) subq_15 ON - subq_13.listing = subq_26.listing - ) subq_27 - ) subq_28 + subq_2.listing = subq_15.listing + ) subq_16 + ) subq_17 WHERE listing__views_times_booking_value > 1 - ) subq_29 - ) subq_30 -) subq_31 + ) subq_18 + ) subq_19 +) subq_20 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql index b55f0f9a34..37ce69c405 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_58.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_45.listings AS listings + subq_36.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_23.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_45 + ) subq_23 LEFT OUTER JOIN ( -- Compute Metrics via Expressions -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] @@ -28,9 +28,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_50.listing, subq_55.listing) AS listing - , MAX(subq_50.booking_value) AS booking_value - , MAX(subq_55.views) AS views + COALESCE(subq_28.listing, subq_33.listing) AS listing + , MAX(subq_28.booking_value) AS booking_value + , MAX(subq_33.views) AS views FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -43,7 +43,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing - ) subq_50 + ) subq_28 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -58,17 +58,17 @@ FROM ( listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_53 + ) subq_31 GROUP BY listing - ) subq_55 + ) subq_33 ON - subq_50.listing = subq_55.listing + subq_28.listing = subq_33.listing GROUP BY listing - ) subq_56 - ) subq_58 + ) subq_34 + ) subq_36 ON - subq_45.listing = subq_58.listing -) subq_60 + subq_23.listing = subq_36.listing +) subq_38 WHERE listing__views_times_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_multiple_metrics_in_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_multiple_metrics_in_filter__plan0.sql index 48e0714983..f48b93b471 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_multiple_metrics_in_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_multiple_metrics_in_filter__plan0.sql @@ -1,108 +1,108 @@ -- Compute Metrics via Expressions SELECT - subq_27.listings + subq_19.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_26.listings) AS listings + SUM(subq_18.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_25.listings + subq_17.listings FROM ( -- Constrain Output with WHERE SELECT - subq_24.listing__bookings - , subq_24.listing__bookers - , subq_24.listings + subq_16.listing__bookings + , subq_16.listing__bookers + , subq_16.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_23.listing__bookings - , subq_23.listing__bookers - , subq_23.listings + subq_15.listing__bookings + , subq_15.listing__bookers + , subq_15.listings FROM ( -- Join Standard Outputs SELECT - subq_10.listing AS listing - , subq_16.listing__bookings AS listing__bookings - , subq_22.listing__bookers AS listing__bookers - , subq_10.listings AS listings + subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_14.listing__bookers AS listing__bookers + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing', 'listing'] SELECT - subq_9.listing - , subq_9.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' 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.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , 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.listings - , subq_8.largest_listing - , subq_8.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -163,130 +163,130 @@ 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_8 - ) subq_9 - ) subq_10 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_15.listing - , subq_15.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_13.listing - , SUM(subq_13.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_12.listing - , subq_12.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.paid_at__day - , subq_11.paid_at__week - , subq_11.paid_at__month - , subq_11.paid_at__quarter - , subq_11.paid_at__year - , subq_11.paid_at__extract_year - , subq_11.paid_at__extract_quarter - , subq_11.paid_at__extract_month - , subq_11.paid_at__extract_day - , subq_11.paid_at__extract_dow - , subq_11.paid_at__extract_doy - , subq_11.booking__ds__day - , subq_11.booking__ds__week - , subq_11.booking__ds__month - , subq_11.booking__ds__quarter - , subq_11.booking__ds__year - , subq_11.booking__ds__extract_year - , subq_11.booking__ds__extract_quarter - , subq_11.booking__ds__extract_month - , subq_11.booking__ds__extract_day - , subq_11.booking__ds__extract_dow - , subq_11.booking__ds__extract_doy - , subq_11.booking__ds_partitioned__day - , subq_11.booking__ds_partitioned__week - , subq_11.booking__ds_partitioned__month - , subq_11.booking__ds_partitioned__quarter - , subq_11.booking__ds_partitioned__year - , subq_11.booking__ds_partitioned__extract_year - , subq_11.booking__ds_partitioned__extract_quarter - , subq_11.booking__ds_partitioned__extract_month - , subq_11.booking__ds_partitioned__extract_day - , subq_11.booking__ds_partitioned__extract_dow - , subq_11.booking__ds_partitioned__extract_doy - , subq_11.booking__paid_at__day - , subq_11.booking__paid_at__week - , subq_11.booking__paid_at__month - , subq_11.booking__paid_at__quarter - , subq_11.booking__paid_at__year - , subq_11.booking__paid_at__extract_year - , subq_11.booking__paid_at__extract_quarter - , subq_11.booking__paid_at__extract_month - , subq_11.booking__paid_at__extract_day - , subq_11.booking__paid_at__extract_dow - , subq_11.booking__paid_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.guest - , subq_11.host - , subq_11.booking__listing - , subq_11.booking__guest - , subq_11.booking__host - , subq_11.is_instant - , subq_11.booking__is_instant - , subq_11.bookings - , subq_11.instant_bookings - , subq_11.booking_value - , subq_11.max_booking_value - , subq_11.min_booking_value - , subq_11.bookers - , subq_11.average_booking_value - , subq_11.referred_bookings - , subq_11.median_booking_value - , subq_11.booking_value_p99 - , subq_11.discrete_booking_value_p99 - , subq_11.approximate_continuous_booking_value_p99 - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -379,137 +379,137 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY listing - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_10.listing = subq_16.listing + subq_2.listing = subq_8.listing LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookers'] SELECT - subq_21.listing - , subq_21.listing__bookers + subq_13.listing + , subq_13.listing__bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_20.listing - , subq_20.bookers AS listing__bookers + subq_12.listing + , subq_12.bookers AS listing__bookers FROM ( -- Aggregate Measures SELECT - subq_19.listing - , COUNT(DISTINCT subq_19.bookers) AS bookers + subq_11.listing + , COUNT(DISTINCT subq_11.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_18.listing - , subq_18.bookers + subq_10.listing + , subq_10.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_17.ds__day - , subq_17.ds__week - , subq_17.ds__month - , subq_17.ds__quarter - , subq_17.ds__year - , subq_17.ds__extract_year - , subq_17.ds__extract_quarter - , subq_17.ds__extract_month - , subq_17.ds__extract_day - , subq_17.ds__extract_dow - , subq_17.ds__extract_doy - , subq_17.ds_partitioned__day - , subq_17.ds_partitioned__week - , subq_17.ds_partitioned__month - , subq_17.ds_partitioned__quarter - , subq_17.ds_partitioned__year - , subq_17.ds_partitioned__extract_year - , subq_17.ds_partitioned__extract_quarter - , subq_17.ds_partitioned__extract_month - , subq_17.ds_partitioned__extract_day - , subq_17.ds_partitioned__extract_dow - , subq_17.ds_partitioned__extract_doy - , subq_17.paid_at__day - , subq_17.paid_at__week - , subq_17.paid_at__month - , subq_17.paid_at__quarter - , subq_17.paid_at__year - , subq_17.paid_at__extract_year - , subq_17.paid_at__extract_quarter - , subq_17.paid_at__extract_month - , subq_17.paid_at__extract_day - , subq_17.paid_at__extract_dow - , subq_17.paid_at__extract_doy - , subq_17.booking__ds__day - , subq_17.booking__ds__week - , subq_17.booking__ds__month - , subq_17.booking__ds__quarter - , subq_17.booking__ds__year - , subq_17.booking__ds__extract_year - , subq_17.booking__ds__extract_quarter - , subq_17.booking__ds__extract_month - , subq_17.booking__ds__extract_day - , subq_17.booking__ds__extract_dow - , subq_17.booking__ds__extract_doy - , subq_17.booking__ds_partitioned__day - , subq_17.booking__ds_partitioned__week - , subq_17.booking__ds_partitioned__month - , subq_17.booking__ds_partitioned__quarter - , subq_17.booking__ds_partitioned__year - , subq_17.booking__ds_partitioned__extract_year - , subq_17.booking__ds_partitioned__extract_quarter - , subq_17.booking__ds_partitioned__extract_month - , subq_17.booking__ds_partitioned__extract_day - , subq_17.booking__ds_partitioned__extract_dow - , subq_17.booking__ds_partitioned__extract_doy - , subq_17.booking__paid_at__day - , subq_17.booking__paid_at__week - , subq_17.booking__paid_at__month - , subq_17.booking__paid_at__quarter - , subq_17.booking__paid_at__year - , subq_17.booking__paid_at__extract_year - , subq_17.booking__paid_at__extract_quarter - , subq_17.booking__paid_at__extract_month - , subq_17.booking__paid_at__extract_day - , subq_17.booking__paid_at__extract_dow - , subq_17.booking__paid_at__extract_doy - , subq_17.ds__day AS metric_time__day - , subq_17.ds__week AS metric_time__week - , subq_17.ds__month AS metric_time__month - , subq_17.ds__quarter AS metric_time__quarter - , subq_17.ds__year AS metric_time__year - , subq_17.ds__extract_year AS metric_time__extract_year - , subq_17.ds__extract_quarter AS metric_time__extract_quarter - , subq_17.ds__extract_month AS metric_time__extract_month - , subq_17.ds__extract_day AS metric_time__extract_day - , subq_17.ds__extract_dow AS metric_time__extract_dow - , subq_17.ds__extract_doy AS metric_time__extract_doy - , subq_17.listing - , subq_17.guest - , subq_17.host - , subq_17.booking__listing - , subq_17.booking__guest - , subq_17.booking__host - , subq_17.is_instant - , subq_17.booking__is_instant - , subq_17.bookings - , subq_17.instant_bookings - , subq_17.booking_value - , subq_17.max_booking_value - , subq_17.min_booking_value - , subq_17.bookers - , subq_17.average_booking_value - , subq_17.referred_bookings - , subq_17.median_booking_value - , subq_17.booking_value_p99 - , subq_17.discrete_booking_value_p99 - , subq_17.approximate_continuous_booking_value_p99 - , subq_17.approximate_discrete_booking_value_p99 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -602,19 +602,19 @@ 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_17 - ) subq_18 - ) subq_19 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY listing - ) subq_20 - ) subq_21 - ) subq_22 + ) subq_12 + ) subq_13 + ) subq_14 ON - subq_10.listing = subq_22.listing - ) subq_23 - ) subq_24 + subq_2.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__bookings > 2 AND listing__bookers > 1 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql index 1f1cc20e05..76e0386b97 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_44.listing__bookings AS listing__bookings - , subq_50.listing__bookers AS listing__bookers - , subq_38.listings AS listings + subq_28.listing__bookings AS listing__bookings + , subq_34.listing__bookers AS listing__bookers + , subq_22.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -19,7 +19,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_38 + ) subq_22 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,12 +35,12 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_41 + ) subq_25 GROUP BY listing - ) subq_44 + ) subq_28 ON - subq_38.listing = subq_44.listing + subq_22.listing = subq_28.listing LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -54,8 +54,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing - ) subq_50 + ) subq_34 ON - subq_38.listing = subq_50.listing -) subq_52 + subq_22.listing = subq_34.listing +) subq_36 WHERE listing__bookings > 2 AND listing__bookers > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_ratio_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_ratio_metric_in_where_filter__plan0.sql index 6aa394d52c..01371f26dc 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_ratio_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_ratio_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_31.listings + subq_20.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_30.listings) AS listings + SUM(subq_19.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_29.listings + subq_18.listings FROM ( -- Constrain Output with WHERE SELECT - subq_28.listing__bookings_per_booker - , subq_28.listings + subq_17.listing__bookings_per_booker + , subq_17.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - subq_27.listing__bookings_per_booker - , subq_27.listings + subq_16.listing__bookings_per_booker + , subq_16.listings FROM ( -- Join Standard Outputs SELECT - subq_13.listing AS listing - , subq_26.listing__bookings_per_booker AS listing__bookings_per_booker - , subq_13.listings AS listings + subq_2.listing AS listing + , subq_15.listing__bookings_per_booker AS listing__bookings_per_booker + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_12.listing - , subq_12.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,141 +160,141 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] SELECT - subq_25.listing - , subq_25.listing__bookings_per_booker + subq_14.listing + , subq_14.listing__bookings_per_booker FROM ( -- Compute Metrics via Expressions SELECT - subq_24.listing - , CAST(subq_24.bookings AS FLOAT64) / CAST(NULLIF(subq_24.bookers, 0) AS FLOAT64) AS listing__bookings_per_booker + subq_13.listing + , CAST(subq_13.bookings AS FLOAT64) / CAST(NULLIF(subq_13.bookers, 0) AS FLOAT64) AS listing__bookings_per_booker FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.listing, subq_23.listing) AS listing - , MAX(subq_18.bookings) AS bookings - , MAX(subq_23.bookers) AS bookers + COALESCE(subq_7.listing, subq_12.listing) AS listing + , MAX(subq_7.bookings) AS bookings + , MAX(subq_12.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_17.listing - , subq_17.bookings + subq_6.listing + , subq_6.bookings FROM ( -- Aggregate Measures SELECT - subq_16.listing - , SUM(subq_16.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_15.listing - , subq_15.bookings + subq_4.listing + , subq_4.bookings 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_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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -387,129 +387,129 @@ 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_3 + ) subq_4 + ) subq_5 GROUP BY listing - ) subq_17 - ) subq_18 + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.listing - , subq_22.bookers + subq_11.listing + , subq_11.bookers FROM ( -- Aggregate Measures SELECT - subq_21.listing - , COUNT(DISTINCT subq_21.bookers) AS bookers + subq_10.listing + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_20.listing - , subq_20.bookers + subq_9.listing + , subq_9.bookers FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -602,25 +602,25 @@ 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_19 - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY listing - ) subq_22 - ) subq_23 + ) subq_11 + ) subq_12 ON - subq_18.listing = subq_23.listing + subq_7.listing = subq_12.listing GROUP BY listing - ) subq_24 - ) subq_25 - ) subq_26 + ) subq_13 + ) subq_14 + ) subq_15 ON - subq_13.listing = subq_26.listing - ) subq_27 - ) subq_28 + subq_2.listing = subq_15.listing + ) subq_16 + ) subq_17 WHERE listing__bookings_per_booker > 1 - ) subq_29 - ) subq_30 -) subq_31 + ) subq_18 + ) subq_19 +) subq_20 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql index 41af0cf281..97e4e327a0 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - CAST(subq_56.bookings AS FLOAT64) / CAST(NULLIF(subq_56.bookers, 0) AS FLOAT64) AS listing__bookings_per_booker - , subq_45.listings AS listings + CAST(subq_34.bookings AS FLOAT64) / CAST(NULLIF(subq_34.bookers, 0) AS FLOAT64) AS listing__bookings_per_booker + , subq_23.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,13 +18,13 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_45 + ) subq_23 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_50.listing, subq_55.listing) AS listing - , MAX(subq_50.bookings) AS bookings - , MAX(subq_55.bookers) AS bookers + COALESCE(subq_28.listing, subq_33.listing) AS listing + , MAX(subq_28.bookings) AS bookings + , MAX(subq_33.bookers) AS bookers FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,10 +39,10 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_48 + ) subq_26 GROUP BY listing - ) subq_50 + ) subq_28 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -55,13 +55,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing - ) subq_55 + ) subq_33 ON - subq_50.listing = subq_55.listing + subq_28.listing = subq_33.listing GROUP BY listing - ) subq_56 + ) subq_34 ON - subq_45.listing = subq_56.listing -) subq_60 + subq_23.listing = subq_34.listing +) subq_38 WHERE listing__bookings_per_booker > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_simple_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_simple_metric_in_where_filter__plan0.sql index b942daec60..6f8291f37d 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_simple_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_simple_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_17.listings + subq_13.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_16.listings) AS listings + SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_15.listings + subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.listing__bookings - , subq_14.listings + subq_10.listing__bookings + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_13.listing__bookings - , subq_13.listings + subq_9.listing__bookings + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.listing AS listing - , subq_12.listing__bookings AS listing__bookings - , subq_6.listings AS listings + subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_5.listing - , subq_5.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,130 +160,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_11.listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing - , SUM(subq_9.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_8.listing - , subq_8.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -376,19 +376,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY listing - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookings > 2 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql index 98bdb265dd..48fed36d03 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_30.listing__bookings AS listing__bookings - , subq_24.listings AS listings + subq_22.listing__bookings AS listing__bookings + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -34,11 +34,11 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_27 + ) subq_19 GROUP BY listing - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookings > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_distinct_values_query_with_metric_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_distinct_values_query_with_metric_filter__plan0.sql index 5ffb3f6a27..bbde80db86 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_distinct_values_query_with_metric_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_distinct_values_query_with_metric_filter__plan0.sql @@ -1,20 +1,20 @@ -- Pass Only Elements: ['listing',] SELECT - subq_12.listing + subq_8.listing FROM ( -- Constrain Output with WHERE SELECT - subq_11.listing - , subq_11.lux_listing - , subq_11.listing__lux_listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.lux_listing + , subq_7.listing__lux_listing + , subq_7.listing__bookings FROM ( -- Join Standard Outputs SELECT - subq_4.listing AS listing - , subq_4.lux_listing AS lux_listing - , subq_4.listing__lux_listing AS listing__lux_listing - , subq_10.listing__bookings AS listing__bookings + subq_0.listing AS listing + , subq_0.lux_listing AS lux_listing + , subq_0.listing__lux_listing AS listing__lux_listing + , subq_6.listing__bookings AS listing__bookings FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -22,128 +22,128 @@ FROM ( , lux_listing_mapping_src_28000.lux_listing_id AS lux_listing , lux_listing_mapping_src_28000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_28000 - ) subq_4 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_9.listing - , subq_9.listing__bookings + subq_5.listing + , subq_5.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.listing - , subq_8.bookings AS listing__bookings + subq_4.listing + , subq_4.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_7.listing - , SUM(subq_7.bookings) AS bookings + subq_3.listing + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_6.listing - , subq_6.bookings + subq_2.listing + , subq_2.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__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 + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -236,18 +236,18 @@ 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_5 - ) subq_6 - ) subq_7 + ) subq_1 + ) subq_2 + ) subq_3 GROUP BY - subq_7.listing - ) subq_8 - ) subq_9 - ) subq_10 + subq_3.listing + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_4.listing = subq_10.listing - ) subq_11 + subq_0.listing = subq_6.listing + ) subq_7 WHERE listing__bookings > 2 -) subq_12 +) subq_8 GROUP BY - subq_12.listing + subq_8.listing diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_distinct_values_query_with_metric_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_distinct_values_query_with_metric_filter__plan0_optimized.sql index cde9c960c5..d79ef0aa09 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_distinct_values_query_with_metric_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_distinct_values_query_with_metric_filter__plan0_optimized.sql @@ -6,7 +6,7 @@ FROM ( -- Join Standard Outputs SELECT lux_listing_mapping_src_28000.listing_id AS listing - , subq_23.listing__bookings AS listing__bookings + , subq_15.listing__bookings AS listing__bookings FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_28000 FULL OUTER JOIN ( -- Aggregate Measures @@ -23,13 +23,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_20 + ) subq_12 GROUP BY listing - ) subq_23 + ) subq_15 ON - lux_listing_mapping_src_28000.listing_id = subq_23.listing -) subq_24 + lux_listing_mapping_src_28000.listing_id = subq_15.listing +) subq_16 WHERE listing__bookings > 2 GROUP BY listing diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql index f11a241a72..c3c28041e7 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql @@ -1,136 +1,136 @@ -- Compute Metrics via Expressions SELECT - subq_17.bookers + subq_13.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_16.bookers) AS bookers + COUNT(DISTINCT subq_12.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_15.bookers + subq_11.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_14.guest__booking_value - , subq_14.bookers + subq_10.guest__booking_value + , subq_10.bookers FROM ( -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_13.guest__booking_value - , subq_13.bookers + subq_9.guest__booking_value + , subq_9.bookers FROM ( -- Join Standard Outputs SELECT - subq_6.guest AS guest - , subq_12.guest__booking_value AS guest__booking_value - , subq_6.bookers AS bookers + subq_2.guest AS guest + , subq_8.guest__booking_value AS guest__booking_value + , subq_2.bookers AS bookers FROM ( -- Pass Only Elements: ['bookers', 'guest'] SELECT - subq_5.guest - , subq_5.bookers + subq_1.guest + , subq_1.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -223,130 +223,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['guest', 'guest__booking_value'] SELECT - subq_11.guest - , subq_11.guest__booking_value + subq_7.guest + , subq_7.guest__booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.guest - , subq_10.booking_value AS guest__booking_value + subq_6.guest + , subq_6.booking_value AS guest__booking_value FROM ( -- Aggregate Measures SELECT - subq_9.guest - , SUM(subq_9.booking_value) AS booking_value + subq_5.guest + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'guest'] SELECT - subq_8.guest - , subq_8.booking_value + subq_4.guest + , subq_4.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -439,19 +439,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.guest - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.guest + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.guest = subq_12.guest - ) subq_13 - ) subq_14 + subq_2.guest = subq_8.guest + ) subq_9 + ) subq_10 WHERE guest__booking_value > 1.00 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql index 7df3ce4738..93d184feee 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_30.guest__booking_value AS guest__booking_value - , subq_24.bookers AS bookers + subq_22.guest__booking_value AS guest__booking_value + , subq_16.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( guest_id AS guest , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY guest_id - ) subq_30 + ) subq_22 ON - subq_24.guest = subq_30.guest -) subq_32 + subq_16.guest = subq_22.guest +) subq_24 WHERE guest__booking_value > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_with_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_with_conversion_metric__plan0.sql index e76b8b835c..4fbbbf75b0 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_with_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_with_conversion_metric__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_39.listings + subq_24.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_38.listings) AS listings + SUM(subq_23.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_37.listings + subq_22.listings FROM ( -- Constrain Output with WHERE SELECT - subq_36.user__visit_buy_conversion_rate - , subq_36.listings + subq_21.user__visit_buy_conversion_rate + , subq_21.listings FROM ( -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - subq_35.user__visit_buy_conversion_rate - , subq_35.listings + subq_20.user__visit_buy_conversion_rate + , subq_20.listings FROM ( -- Join Standard Outputs SELECT - subq_17.user AS user - , subq_34.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate - , subq_17.listings AS listings + subq_2.user AS user + , subq_19.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_16.user - , subq_16.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,79 +160,79 @@ 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_15 - ) subq_16 - ) subq_17 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] SELECT - subq_33.user - , subq_33.user__visit_buy_conversion_rate + subq_18.user + , subq_18.user__visit_buy_conversion_rate FROM ( -- Compute Metrics via Expressions SELECT - subq_32.user - , CAST(subq_32.buys AS DOUBLE) / CAST(NULLIF(subq_32.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate + subq_17.user + , CAST(subq_17.buys AS DOUBLE) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.user, subq_31.user) AS user - , MAX(subq_21.visits) AS visits - , MAX(subq_31.buys) AS buys + COALESCE(subq_6.user, subq_16.user) AS user + , MAX(subq_6.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_20.user - , SUM(subq_20.visits) AS visits + subq_5.user + , SUM(subq_5.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'user'] SELECT - subq_19.user - , subq_19.visits + subq_4.user + , subq_4.visits 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.visit__ds__day - , subq_18.visit__ds__week - , subq_18.visit__ds__month - , subq_18.visit__ds__quarter - , subq_18.visit__ds__year - , subq_18.visit__ds__extract_year - , subq_18.visit__ds__extract_quarter - , subq_18.visit__ds__extract_month - , subq_18.visit__ds__extract_day - , subq_18.visit__ds__extract_dow - , subq_18.visit__ds__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.user - , subq_18.session - , subq_18.visit__user - , subq_18.visit__session - , subq_18.referrer_id - , subq_18.visit__referrer_id - , subq_18.visits - , subq_18.visitors + 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.visit__ds__day + , subq_3.visit__ds__week + , subq_3.visit__ds__month + , subq_3.visit__ds__quarter + , subq_3.visit__ds__year + , subq_3.visit__ds__extract_year + , subq_3.visit__ds__extract_quarter + , subq_3.visit__ds__extract_month + , subq_3.visit__ds__extract_day + , subq_3.visit__ds__extract_dow + , subq_3.visit__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_3.user + , subq_3.session + , subq_3.visit__user + , subq_3.visit__session + , subq_3.referrer_id + , subq_3.visit__referrer_id + , subq_3.visits + , subq_3.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -267,108 +267,108 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_18 - ) subq_19 - ) subq_20 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_20.user - ) subq_21 + subq_5.user + ) subq_6 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_30.user - , SUM(subq_30.buys) AS buys + subq_15.user + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'user'] SELECT - subq_29.user - , subq_29.buys + subq_14.user + , subq_14.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_28.ds__day - , subq_28.user - , subq_28.buys - , subq_28.visits + subq_13.ds__day + , subq_13.user + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_24.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_24.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_24.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_27.mf_internal_uuid AS mf_internal_uuid - , subq_27.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_23.ds__day - , subq_23.user - , subq_23.visits + subq_8.ds__day + , subq_8.user + , subq_8.visits 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.visit__ds__day - , subq_22.visit__ds__week - , subq_22.visit__ds__month - , subq_22.visit__ds__quarter - , subq_22.visit__ds__year - , subq_22.visit__ds__extract_year - , subq_22.visit__ds__extract_quarter - , subq_22.visit__ds__extract_month - , subq_22.visit__ds__extract_day - , subq_22.visit__ds__extract_dow - , subq_22.visit__ds__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.user - , subq_22.session - , subq_22.visit__user - , subq_22.visit__session - , subq_22.referrer_id - , subq_22.visit__referrer_id - , subq_22.visits - , subq_22.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -403,94 +403,94 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_22 - ) subq_23 - ) subq_24 + ) subq_7 + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_26.ds__day - , subq_26.ds__week - , subq_26.ds__month - , subq_26.ds__quarter - , subq_26.ds__year - , subq_26.ds__extract_year - , subq_26.ds__extract_quarter - , subq_26.ds__extract_month - , subq_26.ds__extract_day - , subq_26.ds__extract_dow - , subq_26.ds__extract_doy - , subq_26.buy__ds__day - , subq_26.buy__ds__week - , subq_26.buy__ds__month - , subq_26.buy__ds__quarter - , subq_26.buy__ds__year - , subq_26.buy__ds__extract_year - , subq_26.buy__ds__extract_quarter - , subq_26.buy__ds__extract_month - , subq_26.buy__ds__extract_day - , subq_26.buy__ds__extract_dow - , subq_26.buy__ds__extract_doy - , subq_26.metric_time__day - , subq_26.metric_time__week - , subq_26.metric_time__month - , subq_26.metric_time__quarter - , subq_26.metric_time__year - , subq_26.metric_time__extract_year - , subq_26.metric_time__extract_quarter - , subq_26.metric_time__extract_month - , subq_26.metric_time__extract_day - , subq_26.metric_time__extract_dow - , subq_26.metric_time__extract_doy - , subq_26.user - , subq_26.session_id - , subq_26.buy__user - , subq_26.buy__session_id - , subq_26.buys - , subq_26.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_25.ds__day - , subq_25.ds__week - , subq_25.ds__month - , subq_25.ds__quarter - , subq_25.ds__year - , subq_25.ds__extract_year - , subq_25.ds__extract_quarter - , subq_25.ds__extract_month - , subq_25.ds__extract_day - , subq_25.ds__extract_dow - , subq_25.ds__extract_doy - , subq_25.buy__ds__day - , subq_25.buy__ds__week - , subq_25.buy__ds__month - , subq_25.buy__ds__quarter - , subq_25.buy__ds__year - , subq_25.buy__ds__extract_year - , subq_25.buy__ds__extract_quarter - , subq_25.buy__ds__extract_month - , subq_25.buy__ds__extract_day - , subq_25.buy__ds__extract_dow - , subq_25.buy__ds__extract_doy - , subq_25.ds__day AS metric_time__day - , subq_25.ds__week AS metric_time__week - , subq_25.ds__month AS metric_time__month - , subq_25.ds__quarter AS metric_time__quarter - , subq_25.ds__year AS metric_time__year - , subq_25.ds__extract_year AS metric_time__extract_year - , subq_25.ds__extract_quarter AS metric_time__extract_quarter - , subq_25.ds__extract_month AS metric_time__extract_month - , subq_25.ds__extract_day AS metric_time__extract_day - , subq_25.ds__extract_dow AS metric_time__extract_dow - , subq_25.ds__extract_doy AS metric_time__extract_doy - , subq_25.user - , subq_25.session_id - , subq_25.buy__user - , subq_25.buy__session_id - , subq_25.buys - , subq_25.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -523,33 +523,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_25 - ) subq_26 - ) subq_27 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_24.user = subq_27.user + subq_9.user = subq_12.user ) AND ( - (subq_24.ds__day <= subq_27.ds__day) + (subq_9.ds__day <= subq_12.ds__day) ) - ) subq_28 - ) subq_29 - ) subq_30 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY - subq_30.user - ) subq_31 + subq_15.user + ) subq_16 ON - subq_21.user = subq_31.user + subq_6.user = subq_16.user GROUP BY - COALESCE(subq_21.user, subq_31.user) - ) subq_32 - ) subq_33 - ) subq_34 + COALESCE(subq_6.user, subq_16.user) + ) subq_17 + ) subq_18 + ) subq_19 ON - subq_17.user = subq_34.user - ) subq_35 - ) subq_36 + subq_2.user = subq_19.user + ) subq_20 + ) subq_21 WHERE user__visit_buy_conversion_rate > 2 - ) subq_37 - ) subq_38 -) subq_39 + ) subq_22 + ) subq_23 +) subq_24 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_with_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_with_conversion_metric__plan0_optimized.sql index ba8431aa96..3506f32f8c 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_with_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_with_conversion_metric__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - CAST(subq_72.buys AS DOUBLE) / CAST(NULLIF(subq_72.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate - , subq_57.listings AS listings + CAST(subq_42.buys AS DOUBLE) / CAST(NULLIF(subq_42.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate + , subq_27.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,17 +18,17 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_57 + ) subq_27 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_61.user, subq_71.user) AS user - , MAX(subq_61.visits) AS visits - , MAX(subq_71.buys) AS buys + COALESCE(subq_31.user, subq_41.user) AS user + , MAX(subq_31.visits) AS visits + , MAX(subq_41.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_60.user + subq_30.user , SUM(visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -38,46 +38,46 @@ FROM ( user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_60 + ) subq_30 GROUP BY - subq_60.user - ) subq_61 + subq_30.user + ) subq_31 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'user'] -- Aggregate Measures SELECT - subq_68.user + subq_38.user , SUM(buys) AS buys FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_64.visits) OVER ( + first_value(subq_34.visits) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_64.ds__day) OVER ( + , first_value(subq_34.ds__day) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_64.user) OVER ( + , first_value(subq_34.user) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_67.mf_internal_uuid AS mf_internal_uuid - , subq_67.buys AS buys + , subq_37.mf_internal_uuid AS mf_internal_uuid + , subq_37.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -87,7 +87,7 @@ FROM ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_64 + ) subq_34 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -98,23 +98,23 @@ FROM ( , 1 AS buys , UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_67 + ) subq_37 ON ( - subq_64.user = subq_67.user + subq_34.user = subq_37.user ) AND ( - (subq_64.ds__day <= subq_67.ds__day) + (subq_34.ds__day <= subq_37.ds__day) ) - ) subq_68 + ) subq_38 GROUP BY - subq_68.user - ) subq_71 + subq_38.user + ) subq_41 ON - subq_61.user = subq_71.user + subq_31.user = subq_41.user GROUP BY - COALESCE(subq_61.user, subq_71.user) - ) subq_72 + COALESCE(subq_31.user, subq_41.user) + ) subq_42 ON - subq_57.user = subq_72.user -) subq_76 + subq_27.user = subq_42.user +) subq_46 WHERE user__visit_buy_conversion_rate > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_group_by_has_local_entity_prefix__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_group_by_has_local_entity_prefix__plan0.sql index d28ae74015..331490f28b 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_group_by_has_local_entity_prefix__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_group_by_has_local_entity_prefix__plan0.sql @@ -1,106 +1,106 @@ -- Compute Metrics via Expressions SELECT - subq_27.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_26.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_25.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_24.user__listing__user__average_booking_value - , subq_24.listings + subq_15.user__listing__user__average_booking_value + , subq_15.listings FROM ( -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_23.user__listing__user__average_booking_value - , subq_23.listings + subq_14.user__listing__user__average_booking_value + , subq_14.listings FROM ( -- Join Standard Outputs SELECT - subq_11.user AS user - , subq_22.listing__user AS user__listing__user - , subq_22.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_11.listings AS listings + subq_2.user AS user + , subq_13.listing__user AS user__listing__user + , subq_13.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_10.user - , subq_10.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__extract_quarter - , subq_9.ds__extract_month - , subq_9.ds__extract_day - , subq_9.ds__extract_dow - , subq_9.ds__extract_doy - , subq_9.created_at__day - , subq_9.created_at__week - , subq_9.created_at__month - , subq_9.created_at__quarter - , subq_9.created_at__year - , subq_9.created_at__extract_year - , subq_9.created_at__extract_quarter - , subq_9.created_at__extract_month - , subq_9.created_at__extract_day - , subq_9.created_at__extract_dow - , subq_9.created_at__extract_doy - , subq_9.listing__ds__day - , subq_9.listing__ds__week - , subq_9.listing__ds__month - , subq_9.listing__ds__quarter - , subq_9.listing__ds__year - , subq_9.listing__ds__extract_year - , subq_9.listing__ds__extract_quarter - , subq_9.listing__ds__extract_month - , subq_9.listing__ds__extract_day - , subq_9.listing__ds__extract_dow - , subq_9.listing__ds__extract_doy - , subq_9.listing__created_at__day - , subq_9.listing__created_at__week - , subq_9.listing__created_at__month - , subq_9.listing__created_at__quarter - , subq_9.listing__created_at__year - , subq_9.listing__created_at__extract_year - , subq_9.listing__created_at__extract_quarter - , subq_9.listing__created_at__extract_month - , subq_9.listing__created_at__extract_day - , subq_9.listing__created_at__extract_dow - , subq_9.listing__created_at__extract_doy - , subq_9.ds__day AS metric_time__day - , subq_9.ds__week AS metric_time__week - , subq_9.ds__month AS metric_time__month - , subq_9.ds__quarter AS metric_time__quarter - , subq_9.ds__year AS metric_time__year - , subq_9.ds__extract_year AS metric_time__extract_year - , subq_9.ds__extract_quarter AS metric_time__extract_quarter - , subq_9.ds__extract_month AS metric_time__extract_month - , subq_9.ds__extract_day AS metric_time__extract_day - , subq_9.ds__extract_dow AS metric_time__extract_dow - , subq_9.ds__extract_doy AS metric_time__extract_doy - , subq_9.listing - , subq_9.user - , subq_9.listing__user - , subq_9.country_latest - , subq_9.is_lux_latest - , subq_9.capacity_latest - , subq_9.listing__country_latest - , subq_9.listing__is_lux_latest - , subq_9.listing__capacity_latest - , subq_9.listings - , subq_9.largest_listing - , subq_9.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -161,141 +161,141 @@ 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_9 - ) subq_10 - ) subq_11 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] SELECT - subq_21.listing__user - , subq_21.listing__user__average_booking_value + subq_12.listing__user + , subq_12.listing__user__average_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_20.listing__user - , subq_20.average_booking_value AS listing__user__average_booking_value + subq_11.listing__user + , subq_11.average_booking_value AS listing__user__average_booking_value FROM ( -- Aggregate Measures SELECT - subq_19.listing__user - , AVG(subq_19.average_booking_value) AS average_booking_value + subq_10.listing__user + , AVG(subq_10.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__user'] SELECT - subq_18.listing__user - , subq_18.average_booking_value + subq_9.listing__user + , subq_9.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_14.listing AS listing - , subq_17.user AS listing__user - , subq_14.average_booking_value AS average_booking_value + subq_5.listing AS listing + , subq_8.user AS listing__user + , subq_5.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing'] SELECT - subq_13.listing - , subq_13.average_booking_value + subq_4.listing + , subq_4.average_booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -388,84 +388,84 @@ 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_12 - ) subq_13 - ) subq_14 + ) subq_3 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'user'] SELECT - subq_16.listing - , subq_16.user + subq_7.listing + , subq_7.user FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.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 @@ -526,23 +526,23 @@ 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_15 - ) subq_16 - ) subq_17 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_5.listing = subq_8.listing + ) subq_9 + ) subq_10 GROUP BY - subq_19.listing__user - ) subq_20 - ) subq_21 - ) subq_22 + subq_10.listing__user + ) subq_11 + ) subq_12 + ) subq_13 ON - subq_11.user = subq_22.listing__user - ) subq_23 - ) subq_24 + subq_2.user = subq_13.listing__user + ) subq_14 + ) subq_15 WHERE user__listing__user__average_booking_value > 1 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_group_by_has_local_entity_prefix__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_group_by_has_local_entity_prefix__plan0_optimized.sql index f2d9e26580..8a2de81699 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_group_by_has_local_entity_prefix__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_group_by_has_local_entity_prefix__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_50.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_39.listings AS listings + subq_32.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_21.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_39 + ) subq_21 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__user'] @@ -35,8 +35,8 @@ FROM ( bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY listings_latest_src_28000.user_id - ) subq_50 + ) subq_32 ON - subq_39.user = subq_50.listing__user -) subq_52 + subq_21.user = subq_32.listing__user +) subq_34 WHERE user__listing__user__average_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_multi_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_multi_hop__plan0.sql index 6dc41eb37f..0c8a0cdd59 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_multi_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_multi_hop__plan0.sql @@ -1,76 +1,76 @@ -- Compute Metrics via Expressions SELECT - subq_40.third_hop_count + subq_22.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_39.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_21.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_38.third_hop_count + subq_20.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_37.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_37.third_hop_count + subq_19.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_19.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_36.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_36.third_hop_count + subq_18.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_18.third_hop_count FROM ( -- Join Standard Outputs SELECT - subq_20.customer_third_hop_id AS customer_third_hop_id - , subq_35.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id - , subq_35.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_20.third_hop_count AS third_hop_count + subq_2.customer_third_hop_id AS customer_third_hop_id + , subq_17.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_17.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_2.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_19.customer_third_hop_id - , subq_19.third_hop_count + subq_1.customer_third_hop_id + , subq_1.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - subq_18.third_hop_ds__day - , subq_18.third_hop_ds__week - , subq_18.third_hop_ds__month - , subq_18.third_hop_ds__quarter - , subq_18.third_hop_ds__year - , subq_18.third_hop_ds__extract_year - , subq_18.third_hop_ds__extract_quarter - , subq_18.third_hop_ds__extract_month - , subq_18.third_hop_ds__extract_day - , subq_18.third_hop_ds__extract_dow - , subq_18.third_hop_ds__extract_doy - , subq_18.customer_third_hop_id__third_hop_ds__day - , subq_18.customer_third_hop_id__third_hop_ds__week - , subq_18.customer_third_hop_id__third_hop_ds__month - , subq_18.customer_third_hop_id__third_hop_ds__quarter - , subq_18.customer_third_hop_id__third_hop_ds__year - , subq_18.customer_third_hop_id__third_hop_ds__extract_year - , subq_18.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_18.customer_third_hop_id__third_hop_ds__extract_month - , subq_18.customer_third_hop_id__third_hop_ds__extract_day - , subq_18.customer_third_hop_id__third_hop_ds__extract_dow - , subq_18.customer_third_hop_id__third_hop_ds__extract_doy - , subq_18.third_hop_ds__day AS metric_time__day - , subq_18.third_hop_ds__week AS metric_time__week - , subq_18.third_hop_ds__month AS metric_time__month - , subq_18.third_hop_ds__quarter AS metric_time__quarter - , subq_18.third_hop_ds__year AS metric_time__year - , subq_18.third_hop_ds__extract_year AS metric_time__extract_year - , subq_18.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_18.third_hop_ds__extract_month AS metric_time__extract_month - , subq_18.third_hop_ds__extract_day AS metric_time__extract_day - , subq_18.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_18.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_18.customer_third_hop_id - , subq_18.value - , subq_18.customer_third_hop_id__value - , subq_18.third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( -- Read Elements From Semantic Model 'third_hop_table' SELECT @@ -101,105 +101,105 @@ 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_18 - ) subq_19 - ) subq_20 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_34.account_id__customer_id__customer_third_hop_id - , subq_34.account_id__customer_id__customer_third_hop_id__txn_count + subq_16.account_id__customer_id__customer_third_hop_id + , subq_16.account_id__customer_id__customer_third_hop_id__txn_count FROM ( -- Compute Metrics via Expressions SELECT - subq_33.account_id__customer_id__customer_third_hop_id - , subq_33.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count + subq_15.account_id__customer_id__customer_third_hop_id + , subq_15.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count FROM ( -- Aggregate Measures SELECT - subq_32.account_id__customer_id__customer_third_hop_id - , SUM(subq_32.txn_count) AS txn_count + subq_14.account_id__customer_id__customer_third_hop_id + , SUM(subq_14.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] SELECT - subq_31.account_id__customer_id__customer_third_hop_id - , subq_31.txn_count + subq_13.account_id__customer_id__customer_third_hop_id + , subq_13.txn_count FROM ( -- Join Standard Outputs SELECT - subq_23.ds_partitioned__day AS ds_partitioned__day - , subq_30.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_23.account_id AS account_id - , subq_30.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id - , subq_23.txn_count AS txn_count + subq_5.ds_partitioned__day AS ds_partitioned__day + , subq_12.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_5.account_id AS account_id + , subq_12.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + , subq_5.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_22.ds_partitioned__day - , subq_22.account_id - , subq_22.txn_count + subq_4.ds_partitioned__day + , subq_4.account_id + , subq_4.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_21.ds_partitioned__day - , subq_21.ds_partitioned__week - , subq_21.ds_partitioned__month - , subq_21.ds_partitioned__quarter - , subq_21.ds_partitioned__year - , subq_21.ds_partitioned__extract_year - , subq_21.ds_partitioned__extract_quarter - , subq_21.ds_partitioned__extract_month - , subq_21.ds_partitioned__extract_day - , subq_21.ds_partitioned__extract_dow - , subq_21.ds_partitioned__extract_doy - , subq_21.ds__day - , subq_21.ds__week - , subq_21.ds__month - , subq_21.ds__quarter - , subq_21.ds__year - , subq_21.ds__extract_year - , subq_21.ds__extract_quarter - , subq_21.ds__extract_month - , subq_21.ds__extract_day - , subq_21.ds__extract_dow - , subq_21.ds__extract_doy - , subq_21.account_id__ds_partitioned__day - , subq_21.account_id__ds_partitioned__week - , subq_21.account_id__ds_partitioned__month - , subq_21.account_id__ds_partitioned__quarter - , subq_21.account_id__ds_partitioned__year - , subq_21.account_id__ds_partitioned__extract_year - , subq_21.account_id__ds_partitioned__extract_quarter - , subq_21.account_id__ds_partitioned__extract_month - , subq_21.account_id__ds_partitioned__extract_day - , subq_21.account_id__ds_partitioned__extract_dow - , subq_21.account_id__ds_partitioned__extract_doy - , subq_21.account_id__ds__day - , subq_21.account_id__ds__week - , subq_21.account_id__ds__month - , subq_21.account_id__ds__quarter - , subq_21.account_id__ds__year - , subq_21.account_id__ds__extract_year - , subq_21.account_id__ds__extract_quarter - , subq_21.account_id__ds__extract_month - , subq_21.account_id__ds__extract_day - , subq_21.account_id__ds__extract_dow - , subq_21.account_id__ds__extract_doy - , subq_21.ds__day AS metric_time__day - , subq_21.ds__week AS metric_time__week - , subq_21.ds__month AS metric_time__month - , subq_21.ds__quarter AS metric_time__quarter - , subq_21.ds__year AS metric_time__year - , subq_21.ds__extract_year AS metric_time__extract_year - , subq_21.ds__extract_quarter AS metric_time__extract_quarter - , subq_21.ds__extract_month AS metric_time__extract_month - , subq_21.ds__extract_day AS metric_time__extract_day - , subq_21.ds__extract_dow AS metric_time__extract_dow - , subq_21.ds__extract_doy AS metric_time__extract_doy - , subq_21.account_id - , subq_21.account_month - , subq_21.account_id__account_month - , subq_21.txn_count + 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.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.account_id__ds_partitioned__day + , subq_3.account_id__ds_partitioned__week + , subq_3.account_id__ds_partitioned__month + , subq_3.account_id__ds_partitioned__quarter + , subq_3.account_id__ds_partitioned__year + , subq_3.account_id__ds_partitioned__extract_year + , subq_3.account_id__ds_partitioned__extract_quarter + , subq_3.account_id__ds_partitioned__extract_month + , subq_3.account_id__ds_partitioned__extract_day + , subq_3.account_id__ds_partitioned__extract_dow + , subq_3.account_id__ds_partitioned__extract_doy + , subq_3.account_id__ds__day + , subq_3.account_id__ds__week + , subq_3.account_id__ds__month + , subq_3.account_id__ds__quarter + , subq_3.account_id__ds__year + , subq_3.account_id__ds__extract_year + , subq_3.account_id__ds__extract_quarter + , subq_3.account_id__ds__extract_month + , subq_3.account_id__ds__extract_day + , subq_3.account_id__ds__extract_dow + , subq_3.account_id__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_3.account_id + , subq_3.account_month + , subq_3.account_id__account_month + , subq_3.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -252,164 +252,164 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_3 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] SELECT - subq_29.ds_partitioned__day - , subq_29.account_id - , subq_29.customer_id__customer_third_hop_id + subq_11.ds_partitioned__day + , subq_11.account_id + , subq_11.customer_id__customer_third_hop_id FROM ( -- Join Standard Outputs SELECT - subq_25.ds_partitioned__day AS ds_partitioned__day - , subq_25.ds_partitioned__week AS ds_partitioned__week - , subq_25.ds_partitioned__month AS ds_partitioned__month - , subq_25.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_25.ds_partitioned__year AS ds_partitioned__year - , subq_25.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_25.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_25.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_25.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_25.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_25.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_25.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_25.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_25.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_25.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_25.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_25.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_25.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_25.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_25.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_25.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_25.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_25.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_25.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_25.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_25.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_25.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_25.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_25.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_25.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_25.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_25.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_25.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_25.metric_time__day AS metric_time__day - , subq_25.metric_time__week AS metric_time__week - , subq_25.metric_time__month AS metric_time__month - , subq_25.metric_time__quarter AS metric_time__quarter - , subq_25.metric_time__year AS metric_time__year - , subq_25.metric_time__extract_year AS metric_time__extract_year - , subq_25.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_25.metric_time__extract_month AS metric_time__extract_month - , subq_25.metric_time__extract_day AS metric_time__extract_day - , subq_25.metric_time__extract_dow AS metric_time__extract_dow - , subq_25.metric_time__extract_doy AS metric_time__extract_doy - , subq_28.acquired_ds__day AS customer_id__acquired_ds__day - , subq_28.acquired_ds__week AS customer_id__acquired_ds__week - , subq_28.acquired_ds__month AS customer_id__acquired_ds__month - , subq_28.acquired_ds__quarter AS customer_id__acquired_ds__quarter - , subq_28.acquired_ds__year AS customer_id__acquired_ds__year - , subq_28.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year - , subq_28.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter - , subq_28.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month - , subq_28.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day - , subq_28.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow - , subq_28.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy - , subq_28.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day - , subq_28.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week - , subq_28.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month - , subq_28.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter - , subq_28.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year - , subq_28.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year - , subq_28.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter - , subq_28.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month - , subq_28.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day - , subq_28.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow - , subq_28.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy - , subq_28.metric_time__day AS customer_id__metric_time__day - , subq_28.metric_time__week AS customer_id__metric_time__week - , subq_28.metric_time__month AS customer_id__metric_time__month - , subq_28.metric_time__quarter AS customer_id__metric_time__quarter - , subq_28.metric_time__year AS customer_id__metric_time__year - , subq_28.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_28.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_28.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_28.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_28.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_28.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_25.account_id AS account_id - , subq_25.customer_id AS customer_id - , subq_25.account_id__customer_id AS account_id__customer_id - , subq_25.bridge_account__account_id AS bridge_account__account_id - , subq_25.bridge_account__customer_id AS bridge_account__customer_id - , subq_28.customer_third_hop_id AS customer_id__customer_third_hop_id - , subq_28.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id - , subq_25.extra_dim AS extra_dim - , subq_25.account_id__extra_dim AS account_id__extra_dim - , subq_25.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_28.country AS customer_id__country - , subq_28.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country - , subq_25.account_customer_combos AS account_customer_combos + subq_7.ds_partitioned__day AS ds_partitioned__day + , subq_7.ds_partitioned__week AS ds_partitioned__week + , subq_7.ds_partitioned__month AS ds_partitioned__month + , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_7.ds_partitioned__year AS ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_7.metric_time__day AS metric_time__day + , subq_7.metric_time__week AS metric_time__week + , subq_7.metric_time__month AS metric_time__month + , subq_7.metric_time__quarter AS metric_time__quarter + , subq_7.metric_time__year AS metric_time__year + , subq_7.metric_time__extract_year AS metric_time__extract_year + , subq_7.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_7.metric_time__extract_month AS metric_time__extract_month + , subq_7.metric_time__extract_day AS metric_time__extract_day + , subq_7.metric_time__extract_dow AS metric_time__extract_dow + , subq_7.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.acquired_ds__day AS customer_id__acquired_ds__day + , subq_10.acquired_ds__week AS customer_id__acquired_ds__week + , subq_10.acquired_ds__month AS customer_id__acquired_ds__month + , subq_10.acquired_ds__quarter AS customer_id__acquired_ds__quarter + , subq_10.acquired_ds__year AS customer_id__acquired_ds__year + , subq_10.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year + , subq_10.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter + , subq_10.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month + , subq_10.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day + , subq_10.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow + , subq_10.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy + , subq_10.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day + , subq_10.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week + , subq_10.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month + , subq_10.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter + , subq_10.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year + , subq_10.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year + , subq_10.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter + , subq_10.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month + , subq_10.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day + , subq_10.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow + , subq_10.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy + , subq_10.metric_time__day AS customer_id__metric_time__day + , subq_10.metric_time__week AS customer_id__metric_time__week + , subq_10.metric_time__month AS customer_id__metric_time__month + , subq_10.metric_time__quarter AS customer_id__metric_time__quarter + , subq_10.metric_time__year AS customer_id__metric_time__year + , subq_10.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_10.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_10.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_10.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_10.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_10.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_7.account_id AS account_id + , subq_7.customer_id AS customer_id + , subq_7.account_id__customer_id AS account_id__customer_id + , subq_7.bridge_account__account_id AS bridge_account__account_id + , subq_7.bridge_account__customer_id AS bridge_account__customer_id + , subq_10.customer_third_hop_id AS customer_id__customer_third_hop_id + , subq_10.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id + , subq_7.extra_dim AS extra_dim + , subq_7.account_id__extra_dim AS account_id__extra_dim + , subq_7.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_10.country AS customer_id__country + , subq_10.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country + , subq_7.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.account_id__ds_partitioned__day - , subq_24.account_id__ds_partitioned__week - , subq_24.account_id__ds_partitioned__month - , subq_24.account_id__ds_partitioned__quarter - , subq_24.account_id__ds_partitioned__year - , subq_24.account_id__ds_partitioned__extract_year - , subq_24.account_id__ds_partitioned__extract_quarter - , subq_24.account_id__ds_partitioned__extract_month - , subq_24.account_id__ds_partitioned__extract_day - , subq_24.account_id__ds_partitioned__extract_dow - , subq_24.account_id__ds_partitioned__extract_doy - , subq_24.bridge_account__ds_partitioned__day - , subq_24.bridge_account__ds_partitioned__week - , subq_24.bridge_account__ds_partitioned__month - , subq_24.bridge_account__ds_partitioned__quarter - , subq_24.bridge_account__ds_partitioned__year - , subq_24.bridge_account__ds_partitioned__extract_year - , subq_24.bridge_account__ds_partitioned__extract_quarter - , subq_24.bridge_account__ds_partitioned__extract_month - , subq_24.bridge_account__ds_partitioned__extract_day - , subq_24.bridge_account__ds_partitioned__extract_dow - , subq_24.bridge_account__ds_partitioned__extract_doy - , subq_24.ds_partitioned__day AS metric_time__day - , subq_24.ds_partitioned__week AS metric_time__week - , subq_24.ds_partitioned__month AS metric_time__month - , subq_24.ds_partitioned__quarter AS metric_time__quarter - , subq_24.ds_partitioned__year AS metric_time__year - , subq_24.ds_partitioned__extract_year AS metric_time__extract_year - , subq_24.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_24.ds_partitioned__extract_month AS metric_time__extract_month - , subq_24.ds_partitioned__extract_day AS metric_time__extract_day - , subq_24.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_24.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_24.account_id - , subq_24.customer_id - , subq_24.account_id__customer_id - , subq_24.bridge_account__account_id - , subq_24.bridge_account__customer_id - , subq_24.extra_dim - , subq_24.account_id__extra_dim - , subq_24.bridge_account__extra_dim - , subq_24.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_6.account_id__ds_partitioned__week + , subq_6.account_id__ds_partitioned__month + , subq_6.account_id__ds_partitioned__quarter + , subq_6.account_id__ds_partitioned__year + , subq_6.account_id__ds_partitioned__extract_year + , subq_6.account_id__ds_partitioned__extract_quarter + , subq_6.account_id__ds_partitioned__extract_month + , subq_6.account_id__ds_partitioned__extract_day + , subq_6.account_id__ds_partitioned__extract_dow + , subq_6.account_id__ds_partitioned__extract_doy + , subq_6.bridge_account__ds_partitioned__day + , subq_6.bridge_account__ds_partitioned__week + , subq_6.bridge_account__ds_partitioned__month + , subq_6.bridge_account__ds_partitioned__quarter + , subq_6.bridge_account__ds_partitioned__year + , subq_6.bridge_account__ds_partitioned__extract_year + , subq_6.bridge_account__ds_partitioned__extract_quarter + , subq_6.bridge_account__ds_partitioned__extract_month + , subq_6.bridge_account__ds_partitioned__extract_day + , subq_6.bridge_account__ds_partitioned__extract_dow + , subq_6.bridge_account__ds_partitioned__extract_doy + , subq_6.ds_partitioned__day AS metric_time__day + , subq_6.ds_partitioned__week AS metric_time__week + , subq_6.ds_partitioned__month AS metric_time__month + , subq_6.ds_partitioned__quarter AS metric_time__quarter + , subq_6.ds_partitioned__year AS metric_time__year + , subq_6.ds_partitioned__extract_year AS metric_time__extract_year + , subq_6.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_6.ds_partitioned__extract_month AS metric_time__extract_month + , subq_6.ds_partitioned__extract_day AS metric_time__extract_day + , subq_6.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_6.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_6.account_id + , subq_6.customer_id + , subq_6.account_id__customer_id + , subq_6.bridge_account__account_id + , subq_6.bridge_account__customer_id + , subq_6.extra_dim + , subq_6.account_id__extra_dim + , subq_6.bridge_account__extra_dim + , subq_6.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -456,8 +456,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_24 - ) subq_25 + ) subq_6 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'country', @@ -513,112 +513,112 @@ FROM ( -- 'customer_third_hop_id__customer_id', -- ] SELECT - subq_27.acquired_ds__day - , subq_27.acquired_ds__week - , subq_27.acquired_ds__month - , subq_27.acquired_ds__quarter - , subq_27.acquired_ds__year - , subq_27.acquired_ds__extract_year - , subq_27.acquired_ds__extract_quarter - , subq_27.acquired_ds__extract_month - , subq_27.acquired_ds__extract_day - , subq_27.acquired_ds__extract_dow - , subq_27.acquired_ds__extract_doy - , subq_27.customer_id__acquired_ds__day - , subq_27.customer_id__acquired_ds__week - , subq_27.customer_id__acquired_ds__month - , subq_27.customer_id__acquired_ds__quarter - , subq_27.customer_id__acquired_ds__year - , subq_27.customer_id__acquired_ds__extract_year - , subq_27.customer_id__acquired_ds__extract_quarter - , subq_27.customer_id__acquired_ds__extract_month - , subq_27.customer_id__acquired_ds__extract_day - , subq_27.customer_id__acquired_ds__extract_dow - , subq_27.customer_id__acquired_ds__extract_doy - , subq_27.customer_third_hop_id__acquired_ds__day - , subq_27.customer_third_hop_id__acquired_ds__week - , subq_27.customer_third_hop_id__acquired_ds__month - , subq_27.customer_third_hop_id__acquired_ds__quarter - , subq_27.customer_third_hop_id__acquired_ds__year - , subq_27.customer_third_hop_id__acquired_ds__extract_year - , subq_27.customer_third_hop_id__acquired_ds__extract_quarter - , subq_27.customer_third_hop_id__acquired_ds__extract_month - , subq_27.customer_third_hop_id__acquired_ds__extract_day - , subq_27.customer_third_hop_id__acquired_ds__extract_dow - , subq_27.customer_third_hop_id__acquired_ds__extract_doy - , subq_27.metric_time__day - , subq_27.metric_time__week - , subq_27.metric_time__month - , subq_27.metric_time__quarter - , subq_27.metric_time__year - , subq_27.metric_time__extract_year - , subq_27.metric_time__extract_quarter - , subq_27.metric_time__extract_month - , subq_27.metric_time__extract_day - , subq_27.metric_time__extract_dow - , subq_27.metric_time__extract_doy - , subq_27.customer_id - , subq_27.customer_third_hop_id - , subq_27.customer_id__customer_third_hop_id - , subq_27.customer_third_hop_id__customer_id - , subq_27.country - , subq_27.customer_id__country - , subq_27.customer_third_hop_id__country + subq_9.acquired_ds__day + , subq_9.acquired_ds__week + , subq_9.acquired_ds__month + , subq_9.acquired_ds__quarter + , subq_9.acquired_ds__year + , subq_9.acquired_ds__extract_year + , subq_9.acquired_ds__extract_quarter + , subq_9.acquired_ds__extract_month + , subq_9.acquired_ds__extract_day + , subq_9.acquired_ds__extract_dow + , subq_9.acquired_ds__extract_doy + , subq_9.customer_id__acquired_ds__day + , subq_9.customer_id__acquired_ds__week + , subq_9.customer_id__acquired_ds__month + , subq_9.customer_id__acquired_ds__quarter + , subq_9.customer_id__acquired_ds__year + , subq_9.customer_id__acquired_ds__extract_year + , subq_9.customer_id__acquired_ds__extract_quarter + , subq_9.customer_id__acquired_ds__extract_month + , subq_9.customer_id__acquired_ds__extract_day + , subq_9.customer_id__acquired_ds__extract_dow + , subq_9.customer_id__acquired_ds__extract_doy + , subq_9.customer_third_hop_id__acquired_ds__day + , subq_9.customer_third_hop_id__acquired_ds__week + , subq_9.customer_third_hop_id__acquired_ds__month + , subq_9.customer_third_hop_id__acquired_ds__quarter + , subq_9.customer_third_hop_id__acquired_ds__year + , subq_9.customer_third_hop_id__acquired_ds__extract_year + , subq_9.customer_third_hop_id__acquired_ds__extract_quarter + , subq_9.customer_third_hop_id__acquired_ds__extract_month + , subq_9.customer_third_hop_id__acquired_ds__extract_day + , subq_9.customer_third_hop_id__acquired_ds__extract_dow + , subq_9.customer_third_hop_id__acquired_ds__extract_doy + , subq_9.metric_time__day + , subq_9.metric_time__week + , subq_9.metric_time__month + , subq_9.metric_time__quarter + , subq_9.metric_time__year + , subq_9.metric_time__extract_year + , subq_9.metric_time__extract_quarter + , subq_9.metric_time__extract_month + , subq_9.metric_time__extract_day + , subq_9.metric_time__extract_dow + , subq_9.metric_time__extract_doy + , subq_9.customer_id + , subq_9.customer_third_hop_id + , subq_9.customer_id__customer_third_hop_id + , subq_9.customer_third_hop_id__customer_id + , subq_9.country + , subq_9.customer_id__country + , subq_9.customer_third_hop_id__country FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - subq_26.acquired_ds__day - , subq_26.acquired_ds__week - , subq_26.acquired_ds__month - , subq_26.acquired_ds__quarter - , subq_26.acquired_ds__year - , subq_26.acquired_ds__extract_year - , subq_26.acquired_ds__extract_quarter - , subq_26.acquired_ds__extract_month - , subq_26.acquired_ds__extract_day - , subq_26.acquired_ds__extract_dow - , subq_26.acquired_ds__extract_doy - , subq_26.customer_id__acquired_ds__day - , subq_26.customer_id__acquired_ds__week - , subq_26.customer_id__acquired_ds__month - , subq_26.customer_id__acquired_ds__quarter - , subq_26.customer_id__acquired_ds__year - , subq_26.customer_id__acquired_ds__extract_year - , subq_26.customer_id__acquired_ds__extract_quarter - , subq_26.customer_id__acquired_ds__extract_month - , subq_26.customer_id__acquired_ds__extract_day - , subq_26.customer_id__acquired_ds__extract_dow - , subq_26.customer_id__acquired_ds__extract_doy - , subq_26.customer_third_hop_id__acquired_ds__day - , subq_26.customer_third_hop_id__acquired_ds__week - , subq_26.customer_third_hop_id__acquired_ds__month - , subq_26.customer_third_hop_id__acquired_ds__quarter - , subq_26.customer_third_hop_id__acquired_ds__year - , subq_26.customer_third_hop_id__acquired_ds__extract_year - , subq_26.customer_third_hop_id__acquired_ds__extract_quarter - , subq_26.customer_third_hop_id__acquired_ds__extract_month - , subq_26.customer_third_hop_id__acquired_ds__extract_day - , subq_26.customer_third_hop_id__acquired_ds__extract_dow - , subq_26.customer_third_hop_id__acquired_ds__extract_doy - , subq_26.acquired_ds__day AS metric_time__day - , subq_26.acquired_ds__week AS metric_time__week - , subq_26.acquired_ds__month AS metric_time__month - , subq_26.acquired_ds__quarter AS metric_time__quarter - , subq_26.acquired_ds__year AS metric_time__year - , subq_26.acquired_ds__extract_year AS metric_time__extract_year - , subq_26.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_26.acquired_ds__extract_month AS metric_time__extract_month - , subq_26.acquired_ds__extract_day AS metric_time__extract_day - , subq_26.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_26.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_26.customer_id - , subq_26.customer_third_hop_id - , subq_26.customer_id__customer_third_hop_id - , subq_26.customer_third_hop_id__customer_id - , subq_26.country - , subq_26.customer_id__country - , subq_26.customer_third_hop_id__country - , subq_26.customers_with_other_data + subq_8.acquired_ds__day + , subq_8.acquired_ds__week + , subq_8.acquired_ds__month + , subq_8.acquired_ds__quarter + , subq_8.acquired_ds__year + , subq_8.acquired_ds__extract_year + , subq_8.acquired_ds__extract_quarter + , subq_8.acquired_ds__extract_month + , subq_8.acquired_ds__extract_day + , subq_8.acquired_ds__extract_dow + , subq_8.acquired_ds__extract_doy + , subq_8.customer_id__acquired_ds__day + , subq_8.customer_id__acquired_ds__week + , subq_8.customer_id__acquired_ds__month + , subq_8.customer_id__acquired_ds__quarter + , subq_8.customer_id__acquired_ds__year + , subq_8.customer_id__acquired_ds__extract_year + , subq_8.customer_id__acquired_ds__extract_quarter + , subq_8.customer_id__acquired_ds__extract_month + , subq_8.customer_id__acquired_ds__extract_day + , subq_8.customer_id__acquired_ds__extract_dow + , subq_8.customer_id__acquired_ds__extract_doy + , subq_8.customer_third_hop_id__acquired_ds__day + , subq_8.customer_third_hop_id__acquired_ds__week + , subq_8.customer_third_hop_id__acquired_ds__month + , subq_8.customer_third_hop_id__acquired_ds__quarter + , subq_8.customer_third_hop_id__acquired_ds__year + , subq_8.customer_third_hop_id__acquired_ds__extract_year + , subq_8.customer_third_hop_id__acquired_ds__extract_quarter + , subq_8.customer_third_hop_id__acquired_ds__extract_month + , subq_8.customer_third_hop_id__acquired_ds__extract_day + , subq_8.customer_third_hop_id__acquired_ds__extract_dow + , subq_8.customer_third_hop_id__acquired_ds__extract_doy + , subq_8.acquired_ds__day AS metric_time__day + , subq_8.acquired_ds__week AS metric_time__week + , subq_8.acquired_ds__month AS metric_time__month + , subq_8.acquired_ds__quarter AS metric_time__quarter + , subq_8.acquired_ds__year AS metric_time__year + , subq_8.acquired_ds__extract_year AS metric_time__extract_year + , subq_8.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_8.acquired_ds__extract_month AS metric_time__extract_month + , subq_8.acquired_ds__extract_day AS metric_time__extract_day + , subq_8.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_8.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_8.customer_id + , subq_8.customer_third_hop_id + , subq_8.customer_id__customer_third_hop_id + , subq_8.customer_third_hop_id__customer_id + , subq_8.country + , subq_8.customer_id__country + , subq_8.customer_third_hop_id__country + , subq_8.customers_with_other_data FROM ( -- Read Elements From Semantic Model 'customer_other_data' SELECT @@ -664,31 +664,31 @@ 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_26 - ) subq_27 - ) subq_28 + ) subq_8 + ) subq_9 + ) subq_10 ON - subq_25.customer_id = subq_28.customer_id - ) subq_29 - ) subq_30 + subq_7.customer_id = subq_10.customer_id + ) subq_11 + ) subq_12 ON ( - subq_23.account_id = subq_30.account_id + subq_5.account_id = subq_12.account_id ) AND ( - subq_23.ds_partitioned__day = subq_30.ds_partitioned__day + subq_5.ds_partitioned__day = subq_12.ds_partitioned__day ) - ) subq_31 - ) subq_32 + ) subq_13 + ) subq_14 GROUP BY - subq_32.account_id__customer_id__customer_third_hop_id - ) subq_33 - ) subq_34 - ) subq_35 + subq_14.account_id__customer_id__customer_third_hop_id + ) subq_15 + ) subq_16 + ) subq_17 ON - subq_20.customer_third_hop_id = subq_35.account_id__customer_id__customer_third_hop_id - ) subq_36 - ) subq_37 + subq_2.customer_third_hop_id = subq_17.account_id__customer_id__customer_third_hop_id + ) subq_18 + ) subq_19 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 - ) subq_38 - ) subq_39 -) subq_40 + ) subq_20 + ) subq_21 +) subq_22 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_multi_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_multi_hop__plan0_optimized.sql index bf66de5356..97117da92a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_multi_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_multi_hop__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_76.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + subq_40.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count , 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 ( @@ -18,7 +18,7 @@ FROM ( -- Compute Metrics via Expressions -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_71.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + subq_35.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id , SUM(account_month_txns_src_22000.txn_count) AS account_id__customer_id__customer_third_hop_id__txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -33,17 +33,17 @@ FROM ( ***************************.customer_other_data customer_other_data_src_22000 ON bridge_table_src_22000.customer_id = customer_other_data_src_22000.customer_id - ) subq_71 + ) subq_35 ON ( - account_month_txns_src_22000.account_id = subq_71.account_id + account_month_txns_src_22000.account_id = subq_35.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_71.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_35.ds_partitioned__day ) GROUP BY - subq_71.customer_id__customer_third_hop_id - ) subq_76 + subq_35.customer_id__customer_third_hop_id + ) subq_40 ON - third_hop_table_src_22000.customer_third_hop_id = subq_76.account_id__customer_id__customer_third_hop_id -) subq_78 + third_hop_table_src_22000.customer_third_hop_id = subq_40.account_id__customer_id__customer_third_hop_id +) subq_42 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_single_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_single_hop__plan0.sql index b53d8d1142..49e149d905 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_single_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_single_hop__plan0.sql @@ -1,76 +1,76 @@ -- Compute Metrics via Expressions SELECT - subq_25.third_hop_count + subq_16.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_24.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_15.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_23.third_hop_count + subq_14.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_22.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_22.third_hop_count + subq_13.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_13.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_21.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_21.third_hop_count + subq_12.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_12.third_hop_count FROM ( -- Join Standard Outputs SELECT - 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 + subq_2.customer_third_hop_id AS customer_third_hop_id + , subq_11.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_11.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_2.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_10.customer_third_hop_id - , subq_10.third_hop_count + subq_1.customer_third_hop_id + , subq_1.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - 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 + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.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_9 - ) subq_10 - ) subq_11 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_19.customer_id__customer_third_hop_id - , subq_19.customer_id__customer_third_hop_id__paraguayan_customers + subq_10.customer_id__customer_third_hop_id + , subq_10.customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Compute Metrics via Expressions SELECT - subq_18.customer_id__customer_third_hop_id - , subq_18.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_9.customer_id__customer_third_hop_id + , subq_9.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Aggregate Measures SELECT - subq_17.customer_id__customer_third_hop_id - , SUM(subq_17.customers_with_other_data) AS customers_with_other_data + subq_8.customer_id__customer_third_hop_id + , SUM(subq_8.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_16.customer_id__customer_third_hop_id - , subq_16.customers_with_other_data + subq_7.customer_id__customer_third_hop_id + , subq_7.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_15.customer_id__customer_third_hop_id - , subq_15.customer_id__country - , subq_15.customers_with_other_data + subq_6.customer_id__customer_third_hop_id + , subq_6.customer_id__country + , subq_6.customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT - subq_14.customer_id__customer_third_hop_id - , subq_14.customer_id__country - , subq_14.customers_with_other_data + subq_5.customer_id__customer_third_hop_id + , subq_5.customer_id__country + , subq_5.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - 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 + subq_4.acquired_ds__day + , subq_4.acquired_ds__week + , subq_4.acquired_ds__month + , subq_4.acquired_ds__quarter + , subq_4.acquired_ds__year + , subq_4.acquired_ds__extract_year + , subq_4.acquired_ds__extract_quarter + , subq_4.acquired_ds__extract_month + , subq_4.acquired_ds__extract_day + , subq_4.acquired_ds__extract_dow + , subq_4.acquired_ds__extract_doy + , subq_4.customer_id__acquired_ds__day + , subq_4.customer_id__acquired_ds__week + , subq_4.customer_id__acquired_ds__month + , subq_4.customer_id__acquired_ds__quarter + , subq_4.customer_id__acquired_ds__year + , subq_4.customer_id__acquired_ds__extract_year + , subq_4.customer_id__acquired_ds__extract_quarter + , subq_4.customer_id__acquired_ds__extract_month + , subq_4.customer_id__acquired_ds__extract_day + , subq_4.customer_id__acquired_ds__extract_dow + , subq_4.customer_id__acquired_ds__extract_doy + , subq_4.customer_third_hop_id__acquired_ds__day + , subq_4.customer_third_hop_id__acquired_ds__week + , subq_4.customer_third_hop_id__acquired_ds__month + , subq_4.customer_third_hop_id__acquired_ds__quarter + , subq_4.customer_third_hop_id__acquired_ds__year + , subq_4.customer_third_hop_id__acquired_ds__extract_year + , subq_4.customer_third_hop_id__acquired_ds__extract_quarter + , subq_4.customer_third_hop_id__acquired_ds__extract_month + , subq_4.customer_third_hop_id__acquired_ds__extract_day + , subq_4.customer_third_hop_id__acquired_ds__extract_dow + , subq_4.customer_third_hop_id__acquired_ds__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.customer_id + , subq_4.customer_third_hop_id + , subq_4.customer_id__customer_third_hop_id + , subq_4.customer_third_hop_id__customer_id + , subq_4.country + , subq_4.customer_id__country + , subq_4.customer_third_hop_id__country + , subq_4.customers_with_other_data FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - 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 + subq_3.acquired_ds__day + , subq_3.acquired_ds__week + , subq_3.acquired_ds__month + , subq_3.acquired_ds__quarter + , subq_3.acquired_ds__year + , subq_3.acquired_ds__extract_year + , subq_3.acquired_ds__extract_quarter + , subq_3.acquired_ds__extract_month + , subq_3.acquired_ds__extract_day + , subq_3.acquired_ds__extract_dow + , subq_3.acquired_ds__extract_doy + , subq_3.customer_id__acquired_ds__day + , subq_3.customer_id__acquired_ds__week + , subq_3.customer_id__acquired_ds__month + , subq_3.customer_id__acquired_ds__quarter + , subq_3.customer_id__acquired_ds__year + , subq_3.customer_id__acquired_ds__extract_year + , subq_3.customer_id__acquired_ds__extract_quarter + , subq_3.customer_id__acquired_ds__extract_month + , subq_3.customer_id__acquired_ds__extract_day + , subq_3.customer_id__acquired_ds__extract_dow + , subq_3.customer_id__acquired_ds__extract_doy + , subq_3.customer_third_hop_id__acquired_ds__day + , subq_3.customer_third_hop_id__acquired_ds__week + , subq_3.customer_third_hop_id__acquired_ds__month + , subq_3.customer_third_hop_id__acquired_ds__quarter + , subq_3.customer_third_hop_id__acquired_ds__year + , subq_3.customer_third_hop_id__acquired_ds__extract_year + , subq_3.customer_third_hop_id__acquired_ds__extract_quarter + , subq_3.customer_third_hop_id__acquired_ds__extract_month + , subq_3.customer_third_hop_id__acquired_ds__extract_day + , subq_3.customer_third_hop_id__acquired_ds__extract_dow + , subq_3.customer_third_hop_id__acquired_ds__extract_doy + , subq_3.acquired_ds__day AS metric_time__day + , subq_3.acquired_ds__week AS metric_time__week + , subq_3.acquired_ds__month AS metric_time__month + , subq_3.acquired_ds__quarter AS metric_time__quarter + , subq_3.acquired_ds__year AS metric_time__year + , subq_3.acquired_ds__extract_year AS metric_time__extract_year + , subq_3.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_3.acquired_ds__extract_month AS metric_time__extract_month + , subq_3.acquired_ds__extract_day AS metric_time__extract_day + , subq_3.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_3.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_3.customer_id + , subq_3.customer_third_hop_id + , subq_3.customer_id__customer_third_hop_id + , subq_3.customer_third_hop_id__customer_id + , subq_3.country + , subq_3.customer_id__country + , subq_3.customer_third_hop_id__country + , subq_3.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_12 - ) subq_13 + ) subq_3 + ) subq_4 WHERE customer_id__country = 'paraguay' - ) subq_14 - ) subq_15 + ) subq_5 + ) subq_6 WHERE customer_id__country = 'paraguay' - ) subq_16 - ) subq_17 + ) subq_7 + ) subq_8 GROUP BY - subq_17.customer_id__customer_third_hop_id - ) subq_18 - ) subq_19 - ) subq_20 + subq_8.customer_id__customer_third_hop_id + ) subq_9 + ) subq_10 + ) subq_11 ON - subq_11.customer_third_hop_id = subq_20.customer_id__customer_third_hop_id - ) subq_21 - ) subq_22 + subq_2.customer_third_hop_id = subq_11.customer_id__customer_third_hop_id + ) subq_12 + ) subq_13 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_23 - ) subq_24 -) subq_25 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_single_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_single_hop__plan0_optimized.sql index 0fd2bf1820..b73c99c9a9 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_single_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/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_46.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_28.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_39 + ) subq_21 WHERE customer_id__country = 'paraguay' - ) subq_41 + ) subq_23 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_46 + ) subq_28 ON - third_hop_table_src_22000.customer_third_hop_id = subq_46.customer_id__customer_third_hop_id -) subq_48 + third_hop_table_src_22000.customer_third_hop_id = subq_28.customer_id__customer_third_hop_id +) subq_30 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_filtered_by_itself__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_filtered_by_itself__plan0.sql index 7a3c4f00fe..b787909bd7 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_filtered_by_itself__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_filtered_by_itself__plan0.sql @@ -1,136 +1,136 @@ -- Compute Metrics via Expressions SELECT - subq_17.bookers + subq_13.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_16.bookers) AS bookers + COUNT(DISTINCT subq_12.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_15.bookers + subq_11.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_14.listing__bookers - , subq_14.bookers + subq_10.listing__bookers + , subq_10.bookers FROM ( -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_13.listing__bookers - , subq_13.bookers + subq_9.listing__bookers + , subq_9.bookers FROM ( -- Join Standard Outputs SELECT - subq_6.listing AS listing - , subq_12.listing__bookers AS listing__bookers - , subq_6.bookers AS bookers + subq_2.listing AS listing + , subq_8.listing__bookers AS listing__bookers + , subq_2.bookers AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_5.listing - , subq_5.bookers + subq_1.listing + , subq_1.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -223,130 +223,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookers'] SELECT - subq_11.listing - , subq_11.listing__bookers + subq_7.listing + , subq_7.listing__bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookers AS listing__bookers + subq_6.listing + , subq_6.bookers AS listing__bookers FROM ( -- Aggregate Measures SELECT - subq_9.listing - , COUNT(DISTINCT subq_9.bookers) AS bookers + subq_5.listing + , COUNT(DISTINCT subq_5.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_8.listing - , subq_8.bookers + subq_4.listing + , subq_4.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -439,19 +439,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.listing - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookers > 1.00 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_filtered_by_itself__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_filtered_by_itself__plan0_optimized.sql index e5c7db19a1..fc6f75f09e 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_filtered_by_itself__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_filtered_by_itself__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_30.listing__bookers AS listing__bookers - , subq_24.bookers AS bookers + subq_22.listing__bookers AS listing__bookers + , subq_16.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookers > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_with_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_with_metric_in_where_filter__plan0.sql index 3407014583..e66cb5862b 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_with_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_with_metric_in_where_filter__plan0.sql @@ -1,112 +1,112 @@ -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day - , subq_17.listings AS active_listings + subq_13.metric_time__day + , subq_13.listings AS active_listings FROM ( -- Aggregate Measures SELECT - subq_16.metric_time__day - , SUM(subq_16.listings) AS listings + subq_12.metric_time__day + , SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day'] SELECT - subq_15.metric_time__day - , subq_15.listings + subq_11.metric_time__day + , subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.metric_time__day - , subq_14.listing__bookings - , subq_14.listings + subq_10.metric_time__day + , subq_10.listing__bookings + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_13.metric_time__day - , subq_13.listing__bookings - , subq_13.listings + subq_9.metric_time__day + , subq_9.listing__bookings + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.metric_time__day AS metric_time__day - , subq_6.listing AS listing - , subq_12.listing__bookings AS listing__bookings - , subq_6.listings AS listings + subq_2.metric_time__day AS metric_time__day + , subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] SELECT - subq_5.metric_time__day - , subq_5.listing - , subq_5.listings + subq_1.metric_time__day + , subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -167,130 +167,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_11.listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing - , SUM(subq_9.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_8.listing - , subq_8.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -383,21 +383,21 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.listing - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookings > 2 - ) subq_15 - ) subq_16 + ) subq_11 + ) subq_12 GROUP BY - subq_16.metric_time__day -) subq_17 + subq_12.metric_time__day +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_with_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_with_metric_in_where_filter__plan0_optimized.sql index a43cba6c94..21fd1f7db3 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_with_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_with_metric_in_where_filter__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_24.metric_time__day AS metric_time__day - , subq_30.listing__bookings AS listing__bookings - , subq_24.listings AS listings + subq_16.metric_time__day AS metric_time__day + , subq_22.listing__bookings AS listing__bookings + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -21,7 +21,7 @@ FROM ( , listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -37,13 +37,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_27 + ) subq_19 GROUP BY listing - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookings > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_cumulative_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_cumulative_metric_in_where_filter__plan0.sql index 6870c39244..7286c555a4 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_cumulative_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_cumulative_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_17.listings + subq_13.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_16.listings) AS listings + SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_15.listings + subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.user__revenue_all_time - , subq_14.listings + subq_10.user__revenue_all_time + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_13.user__revenue_all_time - , subq_13.listings + subq_9.user__revenue_all_time + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.user AS user - , subq_12.user__revenue_all_time AS user__revenue_all_time - , subq_6.listings AS listings + subq_2.user AS user + , subq_8.user__revenue_all_time AS user__revenue_all_time + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_5.user - , subq_5.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,68 +160,68 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user', 'user__revenue_all_time'] SELECT - subq_11.user - , subq_11.user__revenue_all_time + subq_7.user + , subq_7.user__revenue_all_time FROM ( -- Compute Metrics via Expressions SELECT - subq_10.user - , subq_10.txn_revenue AS user__revenue_all_time + subq_6.user + , subq_6.txn_revenue AS user__revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_9.user - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_5.user + , SUM(subq_5.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'user'] SELECT - subq_8.user - , subq_8.txn_revenue + subq_4.user + , subq_4.txn_revenue FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.revenue_instance__ds__day - , subq_7.revenue_instance__ds__week - , subq_7.revenue_instance__ds__month - , subq_7.revenue_instance__ds__quarter - , subq_7.revenue_instance__ds__year - , subq_7.revenue_instance__ds__extract_year - , subq_7.revenue_instance__ds__extract_quarter - , subq_7.revenue_instance__ds__extract_month - , subq_7.revenue_instance__ds__extract_day - , subq_7.revenue_instance__ds__extract_dow - , subq_7.revenue_instance__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.revenue_instance__user - , subq_7.txn_revenue + 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.revenue_instance__ds__day + , subq_3.revenue_instance__ds__week + , subq_3.revenue_instance__ds__month + , subq_3.revenue_instance__ds__quarter + , subq_3.revenue_instance__ds__year + , subq_3.revenue_instance__ds__extract_year + , subq_3.revenue_instance__ds__extract_quarter + , subq_3.revenue_instance__ds__extract_month + , subq_3.revenue_instance__ds__extract_day + , subq_3.revenue_instance__ds__extract_dow + , subq_3.revenue_instance__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_3.user + , subq_3.revenue_instance__user + , subq_3.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -251,19 +251,19 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.user - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.user + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.user = subq_12.user - ) subq_13 - ) subq_14 + subq_2.user = subq_8.user + ) subq_9 + ) subq_10 WHERE user__revenue_all_time > 1 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql index 4f006f13ed..2b782589e8 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_30.user__revenue_all_time AS user__revenue_all_time - , subq_24.listings AS listings + subq_22.user__revenue_all_time AS user__revenue_all_time + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_revenue revenue_src_28000 GROUP BY user_id - ) subq_30 + ) subq_22 ON - subq_24.user = subq_30.user -) subq_32 + subq_16.user = subq_22.user +) subq_24 WHERE user__revenue_all_time > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_derived_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_derived_metric_in_where_filter__plan0.sql index fdf044c866..35cc6163cc 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_derived_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_derived_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_31.listings + subq_20.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_30.listings) AS listings + SUM(subq_19.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_29.listings + subq_18.listings FROM ( -- Constrain Output with WHERE SELECT - subq_28.listing__views_times_booking_value - , subq_28.listings + subq_17.listing__views_times_booking_value + , subq_17.listings FROM ( -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_27.listing__views_times_booking_value - , subq_27.listings + subq_16.listing__views_times_booking_value + , subq_16.listings FROM ( -- Join Standard Outputs SELECT - subq_13.listing AS listing - , subq_26.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_13.listings AS listings + subq_2.listing AS listing + , subq_15.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_12.listing - , subq_12.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,141 +160,141 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] SELECT - subq_25.listing - , subq_25.listing__views_times_booking_value + subq_14.listing + , subq_14.listing__views_times_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_24.listing + subq_13.listing , booking_value * views AS listing__views_times_booking_value FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.listing, subq_23.listing) AS listing - , MAX(subq_18.booking_value) AS booking_value - , MAX(subq_23.views) AS views + COALESCE(subq_7.listing, subq_12.listing) AS listing + , MAX(subq_7.booking_value) AS booking_value + , MAX(subq_12.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_17.listing - , subq_17.booking_value + subq_6.listing + , subq_6.booking_value FROM ( -- Aggregate Measures SELECT - subq_16.listing - , SUM(subq_16.booking_value) AS booking_value + subq_5.listing + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'listing'] SELECT - subq_15.listing - , subq_15.booking_value + subq_4.listing + , subq_4.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_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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -387,91 +387,91 @@ 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_3 + ) subq_4 + ) subq_5 GROUP BY - subq_16.listing - ) subq_17 - ) subq_18 + subq_5.listing + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.listing - , subq_22.views + subq_11.listing + , subq_11.views FROM ( -- Aggregate Measures SELECT - subq_21.listing - , SUM(subq_21.views) AS views + subq_10.listing + , SUM(subq_10.views) AS views FROM ( -- Pass Only Elements: ['views', 'listing'] SELECT - subq_20.listing - , subq_20.views + subq_9.listing + , subq_9.views FROM ( -- Metric Time Dimension 'ds' 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.view__ds__day - , subq_19.view__ds__week - , subq_19.view__ds__month - , subq_19.view__ds__quarter - , subq_19.view__ds__year - , subq_19.view__ds__extract_year - , subq_19.view__ds__extract_quarter - , subq_19.view__ds__extract_month - , subq_19.view__ds__extract_day - , subq_19.view__ds__extract_dow - , subq_19.view__ds__extract_doy - , subq_19.view__ds_partitioned__day - , subq_19.view__ds_partitioned__week - , subq_19.view__ds_partitioned__month - , subq_19.view__ds_partitioned__quarter - , subq_19.view__ds_partitioned__year - , subq_19.view__ds_partitioned__extract_year - , subq_19.view__ds_partitioned__extract_quarter - , subq_19.view__ds_partitioned__extract_month - , subq_19.view__ds_partitioned__extract_day - , subq_19.view__ds_partitioned__extract_dow - , subq_19.view__ds_partitioned__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.user - , subq_19.view__listing - , subq_19.view__user - , subq_19.views + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.view__ds__day + , subq_8.view__ds__week + , subq_8.view__ds__month + , subq_8.view__ds__quarter + , subq_8.view__ds__year + , subq_8.view__ds__extract_year + , subq_8.view__ds__extract_quarter + , subq_8.view__ds__extract_month + , subq_8.view__ds__extract_day + , subq_8.view__ds__extract_dow + , subq_8.view__ds__extract_doy + , subq_8.view__ds_partitioned__day + , subq_8.view__ds_partitioned__week + , subq_8.view__ds_partitioned__month + , subq_8.view__ds_partitioned__quarter + , subq_8.view__ds_partitioned__year + , subq_8.view__ds_partitioned__extract_year + , subq_8.view__ds_partitioned__extract_quarter + , subq_8.view__ds_partitioned__extract_month + , subq_8.view__ds_partitioned__extract_day + , subq_8.view__ds_partitioned__extract_dow + , subq_8.view__ds_partitioned__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.user + , subq_8.view__listing + , subq_8.view__user + , subq_8.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT @@ -525,25 +525,25 @@ FROM ( , views_source_src_28000.listing_id AS view__listing , views_source_src_28000.user_id AS view__user FROM ***************************.fct_views views_source_src_28000 - ) subq_19 - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_21.listing - ) subq_22 - ) subq_23 + subq_10.listing + ) subq_11 + ) subq_12 ON - subq_18.listing = subq_23.listing + subq_7.listing = subq_12.listing GROUP BY - COALESCE(subq_18.listing, subq_23.listing) - ) subq_24 - ) subq_25 - ) subq_26 + COALESCE(subq_7.listing, subq_12.listing) + ) subq_13 + ) subq_14 + ) subq_15 ON - subq_13.listing = subq_26.listing - ) subq_27 - ) subq_28 + subq_2.listing = subq_15.listing + ) subq_16 + ) subq_17 WHERE listing__views_times_booking_value > 1 - ) subq_29 - ) subq_30 -) subq_31 + ) subq_18 + ) subq_19 +) subq_20 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql index f8024b63f1..e5f6bf61fb 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_58.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_45.listings AS listings + subq_36.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_23.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_45 + ) subq_23 LEFT OUTER JOIN ( -- Compute Metrics via Expressions -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] @@ -28,9 +28,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_50.listing, subq_55.listing) AS listing - , MAX(subq_50.booking_value) AS booking_value - , MAX(subq_55.views) AS views + COALESCE(subq_28.listing, subq_33.listing) AS listing + , MAX(subq_28.booking_value) AS booking_value + , MAX(subq_33.views) AS views FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -43,7 +43,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_50 + ) subq_28 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -58,17 +58,17 @@ FROM ( listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_53 + ) subq_31 GROUP BY listing - ) subq_55 + ) subq_33 ON - subq_50.listing = subq_55.listing + subq_28.listing = subq_33.listing GROUP BY - COALESCE(subq_50.listing, subq_55.listing) - ) subq_56 - ) subq_58 + COALESCE(subq_28.listing, subq_33.listing) + ) subq_34 + ) subq_36 ON - subq_45.listing = subq_58.listing -) subq_60 + subq_23.listing = subq_36.listing +) subq_38 WHERE listing__views_times_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_multiple_metrics_in_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_multiple_metrics_in_filter__plan0.sql index bf02d2aba6..eeae43d647 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_multiple_metrics_in_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_multiple_metrics_in_filter__plan0.sql @@ -1,108 +1,108 @@ -- Compute Metrics via Expressions SELECT - subq_27.listings + subq_19.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_26.listings) AS listings + SUM(subq_18.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_25.listings + subq_17.listings FROM ( -- Constrain Output with WHERE SELECT - subq_24.listing__bookings - , subq_24.listing__bookers - , subq_24.listings + subq_16.listing__bookings + , subq_16.listing__bookers + , subq_16.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_23.listing__bookings - , subq_23.listing__bookers - , subq_23.listings + subq_15.listing__bookings + , subq_15.listing__bookers + , subq_15.listings FROM ( -- Join Standard Outputs SELECT - subq_10.listing AS listing - , subq_16.listing__bookings AS listing__bookings - , subq_22.listing__bookers AS listing__bookers - , subq_10.listings AS listings + subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_14.listing__bookers AS listing__bookers + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing', 'listing'] SELECT - subq_9.listing - , subq_9.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' 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.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , 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.listings - , subq_8.largest_listing - , subq_8.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -163,130 +163,130 @@ 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_8 - ) subq_9 - ) subq_10 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_15.listing - , subq_15.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_13.listing - , SUM(subq_13.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_12.listing - , subq_12.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.paid_at__day - , subq_11.paid_at__week - , subq_11.paid_at__month - , subq_11.paid_at__quarter - , subq_11.paid_at__year - , subq_11.paid_at__extract_year - , subq_11.paid_at__extract_quarter - , subq_11.paid_at__extract_month - , subq_11.paid_at__extract_day - , subq_11.paid_at__extract_dow - , subq_11.paid_at__extract_doy - , subq_11.booking__ds__day - , subq_11.booking__ds__week - , subq_11.booking__ds__month - , subq_11.booking__ds__quarter - , subq_11.booking__ds__year - , subq_11.booking__ds__extract_year - , subq_11.booking__ds__extract_quarter - , subq_11.booking__ds__extract_month - , subq_11.booking__ds__extract_day - , subq_11.booking__ds__extract_dow - , subq_11.booking__ds__extract_doy - , subq_11.booking__ds_partitioned__day - , subq_11.booking__ds_partitioned__week - , subq_11.booking__ds_partitioned__month - , subq_11.booking__ds_partitioned__quarter - , subq_11.booking__ds_partitioned__year - , subq_11.booking__ds_partitioned__extract_year - , subq_11.booking__ds_partitioned__extract_quarter - , subq_11.booking__ds_partitioned__extract_month - , subq_11.booking__ds_partitioned__extract_day - , subq_11.booking__ds_partitioned__extract_dow - , subq_11.booking__ds_partitioned__extract_doy - , subq_11.booking__paid_at__day - , subq_11.booking__paid_at__week - , subq_11.booking__paid_at__month - , subq_11.booking__paid_at__quarter - , subq_11.booking__paid_at__year - , subq_11.booking__paid_at__extract_year - , subq_11.booking__paid_at__extract_quarter - , subq_11.booking__paid_at__extract_month - , subq_11.booking__paid_at__extract_day - , subq_11.booking__paid_at__extract_dow - , subq_11.booking__paid_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.guest - , subq_11.host - , subq_11.booking__listing - , subq_11.booking__guest - , subq_11.booking__host - , subq_11.is_instant - , subq_11.booking__is_instant - , subq_11.bookings - , subq_11.instant_bookings - , subq_11.booking_value - , subq_11.max_booking_value - , subq_11.min_booking_value - , subq_11.bookers - , subq_11.average_booking_value - , subq_11.referred_bookings - , subq_11.median_booking_value - , subq_11.booking_value_p99 - , subq_11.discrete_booking_value_p99 - , subq_11.approximate_continuous_booking_value_p99 - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -379,137 +379,137 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_13.listing - ) subq_14 - ) subq_15 - ) subq_16 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_10.listing = subq_16.listing + subq_2.listing = subq_8.listing LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookers'] SELECT - subq_21.listing - , subq_21.listing__bookers + subq_13.listing + , subq_13.listing__bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_20.listing - , subq_20.bookers AS listing__bookers + subq_12.listing + , subq_12.bookers AS listing__bookers FROM ( -- Aggregate Measures SELECT - subq_19.listing - , COUNT(DISTINCT subq_19.bookers) AS bookers + subq_11.listing + , COUNT(DISTINCT subq_11.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_18.listing - , subq_18.bookers + subq_10.listing + , subq_10.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_17.ds__day - , subq_17.ds__week - , subq_17.ds__month - , subq_17.ds__quarter - , subq_17.ds__year - , subq_17.ds__extract_year - , subq_17.ds__extract_quarter - , subq_17.ds__extract_month - , subq_17.ds__extract_day - , subq_17.ds__extract_dow - , subq_17.ds__extract_doy - , subq_17.ds_partitioned__day - , subq_17.ds_partitioned__week - , subq_17.ds_partitioned__month - , subq_17.ds_partitioned__quarter - , subq_17.ds_partitioned__year - , subq_17.ds_partitioned__extract_year - , subq_17.ds_partitioned__extract_quarter - , subq_17.ds_partitioned__extract_month - , subq_17.ds_partitioned__extract_day - , subq_17.ds_partitioned__extract_dow - , subq_17.ds_partitioned__extract_doy - , subq_17.paid_at__day - , subq_17.paid_at__week - , subq_17.paid_at__month - , subq_17.paid_at__quarter - , subq_17.paid_at__year - , subq_17.paid_at__extract_year - , subq_17.paid_at__extract_quarter - , subq_17.paid_at__extract_month - , subq_17.paid_at__extract_day - , subq_17.paid_at__extract_dow - , subq_17.paid_at__extract_doy - , subq_17.booking__ds__day - , subq_17.booking__ds__week - , subq_17.booking__ds__month - , subq_17.booking__ds__quarter - , subq_17.booking__ds__year - , subq_17.booking__ds__extract_year - , subq_17.booking__ds__extract_quarter - , subq_17.booking__ds__extract_month - , subq_17.booking__ds__extract_day - , subq_17.booking__ds__extract_dow - , subq_17.booking__ds__extract_doy - , subq_17.booking__ds_partitioned__day - , subq_17.booking__ds_partitioned__week - , subq_17.booking__ds_partitioned__month - , subq_17.booking__ds_partitioned__quarter - , subq_17.booking__ds_partitioned__year - , subq_17.booking__ds_partitioned__extract_year - , subq_17.booking__ds_partitioned__extract_quarter - , subq_17.booking__ds_partitioned__extract_month - , subq_17.booking__ds_partitioned__extract_day - , subq_17.booking__ds_partitioned__extract_dow - , subq_17.booking__ds_partitioned__extract_doy - , subq_17.booking__paid_at__day - , subq_17.booking__paid_at__week - , subq_17.booking__paid_at__month - , subq_17.booking__paid_at__quarter - , subq_17.booking__paid_at__year - , subq_17.booking__paid_at__extract_year - , subq_17.booking__paid_at__extract_quarter - , subq_17.booking__paid_at__extract_month - , subq_17.booking__paid_at__extract_day - , subq_17.booking__paid_at__extract_dow - , subq_17.booking__paid_at__extract_doy - , subq_17.ds__day AS metric_time__day - , subq_17.ds__week AS metric_time__week - , subq_17.ds__month AS metric_time__month - , subq_17.ds__quarter AS metric_time__quarter - , subq_17.ds__year AS metric_time__year - , subq_17.ds__extract_year AS metric_time__extract_year - , subq_17.ds__extract_quarter AS metric_time__extract_quarter - , subq_17.ds__extract_month AS metric_time__extract_month - , subq_17.ds__extract_day AS metric_time__extract_day - , subq_17.ds__extract_dow AS metric_time__extract_dow - , subq_17.ds__extract_doy AS metric_time__extract_doy - , subq_17.listing - , subq_17.guest - , subq_17.host - , subq_17.booking__listing - , subq_17.booking__guest - , subq_17.booking__host - , subq_17.is_instant - , subq_17.booking__is_instant - , subq_17.bookings - , subq_17.instant_bookings - , subq_17.booking_value - , subq_17.max_booking_value - , subq_17.min_booking_value - , subq_17.bookers - , subq_17.average_booking_value - , subq_17.referred_bookings - , subq_17.median_booking_value - , subq_17.booking_value_p99 - , subq_17.discrete_booking_value_p99 - , subq_17.approximate_continuous_booking_value_p99 - , subq_17.approximate_discrete_booking_value_p99 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -602,19 +602,19 @@ 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_17 - ) subq_18 - ) subq_19 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_19.listing - ) subq_20 - ) subq_21 - ) subq_22 + subq_11.listing + ) subq_12 + ) subq_13 + ) subq_14 ON - subq_10.listing = subq_22.listing - ) subq_23 - ) subq_24 + subq_2.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__bookings > 2 AND listing__bookers > 1 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql index 1846b78cd5..767f0b3fea 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_44.listing__bookings AS listing__bookings - , subq_50.listing__bookers AS listing__bookers - , subq_38.listings AS listings + subq_28.listing__bookings AS listing__bookings + , subq_34.listing__bookers AS listing__bookers + , subq_22.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -19,7 +19,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_38 + ) subq_22 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,12 +35,12 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_41 + ) subq_25 GROUP BY listing - ) subq_44 + ) subq_28 ON - subq_38.listing = subq_44.listing + subq_22.listing = subq_28.listing LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -54,8 +54,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_50 + ) subq_34 ON - subq_38.listing = subq_50.listing -) subq_52 + subq_22.listing = subq_34.listing +) subq_36 WHERE listing__bookings > 2 AND listing__bookers > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_ratio_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_ratio_metric_in_where_filter__plan0.sql index 5f009fd2f0..31096cf73a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_ratio_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_ratio_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_31.listings + subq_20.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_30.listings) AS listings + SUM(subq_19.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_29.listings + subq_18.listings FROM ( -- Constrain Output with WHERE SELECT - subq_28.listing__bookings_per_booker - , subq_28.listings + subq_17.listing__bookings_per_booker + , subq_17.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - subq_27.listing__bookings_per_booker - , subq_27.listings + subq_16.listing__bookings_per_booker + , subq_16.listings FROM ( -- Join Standard Outputs SELECT - subq_13.listing AS listing - , subq_26.listing__bookings_per_booker AS listing__bookings_per_booker - , subq_13.listings AS listings + subq_2.listing AS listing + , subq_15.listing__bookings_per_booker AS listing__bookings_per_booker + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_12.listing - , subq_12.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,141 +160,141 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] SELECT - subq_25.listing - , subq_25.listing__bookings_per_booker + subq_14.listing + , subq_14.listing__bookings_per_booker FROM ( -- Compute Metrics via Expressions SELECT - subq_24.listing - , CAST(subq_24.bookings AS DOUBLE) / CAST(NULLIF(subq_24.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker + subq_13.listing + , CAST(subq_13.bookings AS DOUBLE) / CAST(NULLIF(subq_13.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.listing, subq_23.listing) AS listing - , MAX(subq_18.bookings) AS bookings - , MAX(subq_23.bookers) AS bookers + COALESCE(subq_7.listing, subq_12.listing) AS listing + , MAX(subq_7.bookings) AS bookings + , MAX(subq_12.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_17.listing - , subq_17.bookings + subq_6.listing + , subq_6.bookings FROM ( -- Aggregate Measures SELECT - subq_16.listing - , SUM(subq_16.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_15.listing - , subq_15.bookings + subq_4.listing + , subq_4.bookings 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_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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -387,129 +387,129 @@ 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_3 + ) subq_4 + ) subq_5 GROUP BY - subq_16.listing - ) subq_17 - ) subq_18 + subq_5.listing + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.listing - , subq_22.bookers + subq_11.listing + , subq_11.bookers FROM ( -- Aggregate Measures SELECT - subq_21.listing - , COUNT(DISTINCT subq_21.bookers) AS bookers + subq_10.listing + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_20.listing - , subq_20.bookers + subq_9.listing + , subq_9.bookers FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -602,25 +602,25 @@ 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_19 - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_21.listing - ) subq_22 - ) subq_23 + subq_10.listing + ) subq_11 + ) subq_12 ON - subq_18.listing = subq_23.listing + subq_7.listing = subq_12.listing GROUP BY - COALESCE(subq_18.listing, subq_23.listing) - ) subq_24 - ) subq_25 - ) subq_26 + COALESCE(subq_7.listing, subq_12.listing) + ) subq_13 + ) subq_14 + ) subq_15 ON - subq_13.listing = subq_26.listing - ) subq_27 - ) subq_28 + subq_2.listing = subq_15.listing + ) subq_16 + ) subq_17 WHERE listing__bookings_per_booker > 1 - ) subq_29 - ) subq_30 -) subq_31 + ) subq_18 + ) subq_19 +) subq_20 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql index 35d30ee209..86e90a968e 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - CAST(subq_56.bookings AS DOUBLE) / CAST(NULLIF(subq_56.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker - , subq_45.listings AS listings + CAST(subq_34.bookings AS DOUBLE) / CAST(NULLIF(subq_34.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker + , subq_23.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,13 +18,13 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_45 + ) subq_23 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_50.listing, subq_55.listing) AS listing - , MAX(subq_50.bookings) AS bookings - , MAX(subq_55.bookers) AS bookers + COALESCE(subq_28.listing, subq_33.listing) AS listing + , MAX(subq_28.bookings) AS bookings + , MAX(subq_33.bookers) AS bookers FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,10 +39,10 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_48 + ) subq_26 GROUP BY listing - ) subq_50 + ) subq_28 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -55,13 +55,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_55 + ) subq_33 ON - subq_50.listing = subq_55.listing + subq_28.listing = subq_33.listing GROUP BY - COALESCE(subq_50.listing, subq_55.listing) - ) subq_56 + COALESCE(subq_28.listing, subq_33.listing) + ) subq_34 ON - subq_45.listing = subq_56.listing -) subq_60 + subq_23.listing = subq_34.listing +) subq_38 WHERE listing__bookings_per_booker > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_simple_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_simple_metric_in_where_filter__plan0.sql index 96e4424a81..d3b41f9913 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_simple_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_simple_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_17.listings + subq_13.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_16.listings) AS listings + SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_15.listings + subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.listing__bookings - , subq_14.listings + subq_10.listing__bookings + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_13.listing__bookings - , subq_13.listings + subq_9.listing__bookings + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.listing AS listing - , subq_12.listing__bookings AS listing__bookings - , subq_6.listings AS listings + subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_5.listing - , subq_5.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,130 +160,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_11.listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing - , SUM(subq_9.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_8.listing - , subq_8.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -376,19 +376,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.listing - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookings > 2 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql index 98bdb265dd..48fed36d03 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_30.listing__bookings AS listing__bookings - , subq_24.listings AS listings + subq_22.listing__bookings AS listing__bookings + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -34,11 +34,11 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_27 + ) subq_19 GROUP BY listing - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookings > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_distinct_values_query_with_metric_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_distinct_values_query_with_metric_filter__plan0.sql index 5b3e98decc..799e437abe 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_distinct_values_query_with_metric_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_distinct_values_query_with_metric_filter__plan0.sql @@ -1,20 +1,20 @@ -- Pass Only Elements: ['listing',] SELECT - subq_12.listing + subq_8.listing FROM ( -- Constrain Output with WHERE SELECT - subq_11.listing - , subq_11.lux_listing - , subq_11.listing__lux_listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.lux_listing + , subq_7.listing__lux_listing + , subq_7.listing__bookings FROM ( -- Join Standard Outputs SELECT - subq_4.listing AS listing - , subq_4.lux_listing AS lux_listing - , subq_4.listing__lux_listing AS listing__lux_listing - , subq_10.listing__bookings AS listing__bookings + subq_0.listing AS listing + , subq_0.lux_listing AS lux_listing + , subq_0.listing__lux_listing AS listing__lux_listing + , subq_6.listing__bookings AS listing__bookings FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -22,128 +22,128 @@ FROM ( , lux_listing_mapping_src_28000.lux_listing_id AS lux_listing , lux_listing_mapping_src_28000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_28000 - ) subq_4 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_9.listing - , subq_9.listing__bookings + subq_5.listing + , subq_5.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.listing - , subq_8.bookings AS listing__bookings + subq_4.listing + , subq_4.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_7.listing - , SUM(subq_7.bookings) AS bookings + subq_3.listing + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_6.listing - , subq_6.bookings + subq_2.listing + , subq_2.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__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 + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -236,18 +236,18 @@ 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_5 - ) subq_6 - ) subq_7 + ) subq_1 + ) subq_2 + ) subq_3 GROUP BY - subq_7.listing - ) subq_8 - ) subq_9 - ) subq_10 + subq_3.listing + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_4.listing = subq_10.listing - ) subq_11 + subq_0.listing = subq_6.listing + ) subq_7 WHERE listing__bookings > 2 -) subq_12 +) subq_8 GROUP BY - subq_12.listing + subq_8.listing diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_distinct_values_query_with_metric_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_distinct_values_query_with_metric_filter__plan0_optimized.sql index cde9c960c5..d79ef0aa09 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_distinct_values_query_with_metric_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_distinct_values_query_with_metric_filter__plan0_optimized.sql @@ -6,7 +6,7 @@ FROM ( -- Join Standard Outputs SELECT lux_listing_mapping_src_28000.listing_id AS listing - , subq_23.listing__bookings AS listing__bookings + , subq_15.listing__bookings AS listing__bookings FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_28000 FULL OUTER JOIN ( -- Aggregate Measures @@ -23,13 +23,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_20 + ) subq_12 GROUP BY listing - ) subq_23 + ) subq_15 ON - lux_listing_mapping_src_28000.listing_id = subq_23.listing -) subq_24 + lux_listing_mapping_src_28000.listing_id = subq_15.listing +) subq_16 WHERE listing__bookings > 2 GROUP BY listing diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql index 3a179c91bc..e5dc490b67 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql @@ -1,136 +1,136 @@ -- Compute Metrics via Expressions SELECT - subq_17.bookers + subq_13.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_16.bookers) AS bookers + COUNT(DISTINCT subq_12.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_15.bookers + subq_11.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_14.guest__booking_value - , subq_14.bookers + subq_10.guest__booking_value + , subq_10.bookers FROM ( -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_13.guest__booking_value - , subq_13.bookers + subq_9.guest__booking_value + , subq_9.bookers FROM ( -- Join Standard Outputs SELECT - subq_6.guest AS guest - , subq_12.guest__booking_value AS guest__booking_value - , subq_6.bookers AS bookers + subq_2.guest AS guest + , subq_8.guest__booking_value AS guest__booking_value + , subq_2.bookers AS bookers FROM ( -- Pass Only Elements: ['bookers', 'guest'] SELECT - subq_5.guest - , subq_5.bookers + subq_1.guest + , subq_1.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -223,130 +223,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['guest', 'guest__booking_value'] SELECT - subq_11.guest - , subq_11.guest__booking_value + subq_7.guest + , subq_7.guest__booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.guest - , subq_10.booking_value AS guest__booking_value + subq_6.guest + , subq_6.booking_value AS guest__booking_value FROM ( -- Aggregate Measures SELECT - subq_9.guest - , SUM(subq_9.booking_value) AS booking_value + subq_5.guest + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'guest'] SELECT - subq_8.guest - , subq_8.booking_value + subq_4.guest + , subq_4.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -439,19 +439,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.guest - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.guest + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.guest = subq_12.guest - ) subq_13 - ) subq_14 + subq_2.guest = subq_8.guest + ) subq_9 + ) subq_10 WHERE guest__booking_value > 1.00 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql index 7df3ce4738..93d184feee 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_30.guest__booking_value AS guest__booking_value - , subq_24.bookers AS bookers + subq_22.guest__booking_value AS guest__booking_value + , subq_16.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( guest_id AS guest , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY guest_id - ) subq_30 + ) subq_22 ON - subq_24.guest = subq_30.guest -) subq_32 + subq_16.guest = subq_22.guest +) subq_24 WHERE guest__booking_value > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_with_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_with_conversion_metric__plan0.sql index eacffcef29..e442194753 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_with_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_with_conversion_metric__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_39.listings + subq_24.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_38.listings) AS listings + SUM(subq_23.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_37.listings + subq_22.listings FROM ( -- Constrain Output with WHERE SELECT - subq_36.user__visit_buy_conversion_rate - , subq_36.listings + subq_21.user__visit_buy_conversion_rate + , subq_21.listings FROM ( -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - subq_35.user__visit_buy_conversion_rate - , subq_35.listings + subq_20.user__visit_buy_conversion_rate + , subq_20.listings FROM ( -- Join Standard Outputs SELECT - subq_17.user AS user - , subq_34.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate - , subq_17.listings AS listings + subq_2.user AS user + , subq_19.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_16.user - , subq_16.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,79 +160,79 @@ 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_15 - ) subq_16 - ) subq_17 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] SELECT - subq_33.user - , subq_33.user__visit_buy_conversion_rate + subq_18.user + , subq_18.user__visit_buy_conversion_rate FROM ( -- Compute Metrics via Expressions SELECT - subq_32.user - , CAST(subq_32.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_32.visits, 0) AS DOUBLE PRECISION) AS user__visit_buy_conversion_rate + subq_17.user + , CAST(subq_17.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE PRECISION) AS user__visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.user, subq_31.user) AS user - , MAX(subq_21.visits) AS visits - , MAX(subq_31.buys) AS buys + COALESCE(subq_6.user, subq_16.user) AS user + , MAX(subq_6.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_20.user - , SUM(subq_20.visits) AS visits + subq_5.user + , SUM(subq_5.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'user'] SELECT - subq_19.user - , subq_19.visits + subq_4.user + , subq_4.visits 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.visit__ds__day - , subq_18.visit__ds__week - , subq_18.visit__ds__month - , subq_18.visit__ds__quarter - , subq_18.visit__ds__year - , subq_18.visit__ds__extract_year - , subq_18.visit__ds__extract_quarter - , subq_18.visit__ds__extract_month - , subq_18.visit__ds__extract_day - , subq_18.visit__ds__extract_dow - , subq_18.visit__ds__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.user - , subq_18.session - , subq_18.visit__user - , subq_18.visit__session - , subq_18.referrer_id - , subq_18.visit__referrer_id - , subq_18.visits - , subq_18.visitors + 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.visit__ds__day + , subq_3.visit__ds__week + , subq_3.visit__ds__month + , subq_3.visit__ds__quarter + , subq_3.visit__ds__year + , subq_3.visit__ds__extract_year + , subq_3.visit__ds__extract_quarter + , subq_3.visit__ds__extract_month + , subq_3.visit__ds__extract_day + , subq_3.visit__ds__extract_dow + , subq_3.visit__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_3.user + , subq_3.session + , subq_3.visit__user + , subq_3.visit__session + , subq_3.referrer_id + , subq_3.visit__referrer_id + , subq_3.visits + , subq_3.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -267,108 +267,108 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_18 - ) subq_19 - ) subq_20 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_20.user - ) subq_21 + subq_5.user + ) subq_6 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_30.user - , SUM(subq_30.buys) AS buys + subq_15.user + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'user'] SELECT - subq_29.user - , subq_29.buys + subq_14.user + , subq_14.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_28.ds__day - , subq_28.user - , subq_28.buys - , subq_28.visits + subq_13.ds__day + , subq_13.user + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_24.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_24.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_24.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_27.mf_internal_uuid AS mf_internal_uuid - , subq_27.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_23.ds__day - , subq_23.user - , subq_23.visits + subq_8.ds__day + , subq_8.user + , subq_8.visits 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.visit__ds__day - , subq_22.visit__ds__week - , subq_22.visit__ds__month - , subq_22.visit__ds__quarter - , subq_22.visit__ds__year - , subq_22.visit__ds__extract_year - , subq_22.visit__ds__extract_quarter - , subq_22.visit__ds__extract_month - , subq_22.visit__ds__extract_day - , subq_22.visit__ds__extract_dow - , subq_22.visit__ds__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.user - , subq_22.session - , subq_22.visit__user - , subq_22.visit__session - , subq_22.referrer_id - , subq_22.visit__referrer_id - , subq_22.visits - , subq_22.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -403,94 +403,94 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_22 - ) subq_23 - ) subq_24 + ) subq_7 + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_26.ds__day - , subq_26.ds__week - , subq_26.ds__month - , subq_26.ds__quarter - , subq_26.ds__year - , subq_26.ds__extract_year - , subq_26.ds__extract_quarter - , subq_26.ds__extract_month - , subq_26.ds__extract_day - , subq_26.ds__extract_dow - , subq_26.ds__extract_doy - , subq_26.buy__ds__day - , subq_26.buy__ds__week - , subq_26.buy__ds__month - , subq_26.buy__ds__quarter - , subq_26.buy__ds__year - , subq_26.buy__ds__extract_year - , subq_26.buy__ds__extract_quarter - , subq_26.buy__ds__extract_month - , subq_26.buy__ds__extract_day - , subq_26.buy__ds__extract_dow - , subq_26.buy__ds__extract_doy - , subq_26.metric_time__day - , subq_26.metric_time__week - , subq_26.metric_time__month - , subq_26.metric_time__quarter - , subq_26.metric_time__year - , subq_26.metric_time__extract_year - , subq_26.metric_time__extract_quarter - , subq_26.metric_time__extract_month - , subq_26.metric_time__extract_day - , subq_26.metric_time__extract_dow - , subq_26.metric_time__extract_doy - , subq_26.user - , subq_26.session_id - , subq_26.buy__user - , subq_26.buy__session_id - , subq_26.buys - , subq_26.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_25.ds__day - , subq_25.ds__week - , subq_25.ds__month - , subq_25.ds__quarter - , subq_25.ds__year - , subq_25.ds__extract_year - , subq_25.ds__extract_quarter - , subq_25.ds__extract_month - , subq_25.ds__extract_day - , subq_25.ds__extract_dow - , subq_25.ds__extract_doy - , subq_25.buy__ds__day - , subq_25.buy__ds__week - , subq_25.buy__ds__month - , subq_25.buy__ds__quarter - , subq_25.buy__ds__year - , subq_25.buy__ds__extract_year - , subq_25.buy__ds__extract_quarter - , subq_25.buy__ds__extract_month - , subq_25.buy__ds__extract_day - , subq_25.buy__ds__extract_dow - , subq_25.buy__ds__extract_doy - , subq_25.ds__day AS metric_time__day - , subq_25.ds__week AS metric_time__week - , subq_25.ds__month AS metric_time__month - , subq_25.ds__quarter AS metric_time__quarter - , subq_25.ds__year AS metric_time__year - , subq_25.ds__extract_year AS metric_time__extract_year - , subq_25.ds__extract_quarter AS metric_time__extract_quarter - , subq_25.ds__extract_month AS metric_time__extract_month - , subq_25.ds__extract_day AS metric_time__extract_day - , subq_25.ds__extract_dow AS metric_time__extract_dow - , subq_25.ds__extract_doy AS metric_time__extract_doy - , subq_25.user - , subq_25.session_id - , subq_25.buy__user - , subq_25.buy__session_id - , subq_25.buys - , subq_25.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -523,33 +523,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_25 - ) subq_26 - ) subq_27 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_24.user = subq_27.user + subq_9.user = subq_12.user ) AND ( - (subq_24.ds__day <= subq_27.ds__day) + (subq_9.ds__day <= subq_12.ds__day) ) - ) subq_28 - ) subq_29 - ) subq_30 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY - subq_30.user - ) subq_31 + subq_15.user + ) subq_16 ON - subq_21.user = subq_31.user + subq_6.user = subq_16.user GROUP BY - COALESCE(subq_21.user, subq_31.user) - ) subq_32 - ) subq_33 - ) subq_34 + COALESCE(subq_6.user, subq_16.user) + ) subq_17 + ) subq_18 + ) subq_19 ON - subq_17.user = subq_34.user - ) subq_35 - ) subq_36 + subq_2.user = subq_19.user + ) subq_20 + ) subq_21 WHERE user__visit_buy_conversion_rate > 2 - ) subq_37 - ) subq_38 -) subq_39 + ) subq_22 + ) subq_23 +) subq_24 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_with_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_with_conversion_metric__plan0_optimized.sql index 49b180975f..5da1a575ef 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_with_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_with_conversion_metric__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - CAST(subq_72.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_72.visits, 0) AS DOUBLE PRECISION) AS user__visit_buy_conversion_rate - , subq_57.listings AS listings + CAST(subq_42.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_42.visits, 0) AS DOUBLE PRECISION) AS user__visit_buy_conversion_rate + , subq_27.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,17 +18,17 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_57 + ) subq_27 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_61.user, subq_71.user) AS user - , MAX(subq_61.visits) AS visits - , MAX(subq_71.buys) AS buys + COALESCE(subq_31.user, subq_41.user) AS user + , MAX(subq_31.visits) AS visits + , MAX(subq_41.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_60.user + subq_30.user , SUM(visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -38,46 +38,46 @@ FROM ( user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_60 + ) subq_30 GROUP BY - subq_60.user - ) subq_61 + subq_30.user + ) subq_31 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'user'] -- Aggregate Measures SELECT - subq_68.user + subq_38.user , SUM(buys) AS buys FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_64.visits) OVER ( + first_value(subq_34.visits) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_64.ds__day) OVER ( + , first_value(subq_34.ds__day) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_64.user) OVER ( + , first_value(subq_34.user) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_67.mf_internal_uuid AS mf_internal_uuid - , subq_67.buys AS buys + , subq_37.mf_internal_uuid AS mf_internal_uuid + , subq_37.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -87,7 +87,7 @@ FROM ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_64 + ) subq_34 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -98,23 +98,23 @@ FROM ( , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_67 + ) subq_37 ON ( - subq_64.user = subq_67.user + subq_34.user = subq_37.user ) AND ( - (subq_64.ds__day <= subq_67.ds__day) + (subq_34.ds__day <= subq_37.ds__day) ) - ) subq_68 + ) subq_38 GROUP BY - subq_68.user - ) subq_71 + subq_38.user + ) subq_41 ON - subq_61.user = subq_71.user + subq_31.user = subq_41.user GROUP BY - COALESCE(subq_61.user, subq_71.user) - ) subq_72 + COALESCE(subq_31.user, subq_41.user) + ) subq_42 ON - subq_57.user = subq_72.user -) subq_76 + subq_27.user = subq_42.user +) subq_46 WHERE user__visit_buy_conversion_rate > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_group_by_has_local_entity_prefix__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_group_by_has_local_entity_prefix__plan0.sql index e0c25eaedf..1b6946e2c8 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_group_by_has_local_entity_prefix__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_group_by_has_local_entity_prefix__plan0.sql @@ -1,106 +1,106 @@ -- Compute Metrics via Expressions SELECT - subq_27.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_26.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_25.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_24.user__listing__user__average_booking_value - , subq_24.listings + subq_15.user__listing__user__average_booking_value + , subq_15.listings FROM ( -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_23.user__listing__user__average_booking_value - , subq_23.listings + subq_14.user__listing__user__average_booking_value + , subq_14.listings FROM ( -- Join Standard Outputs SELECT - subq_11.user AS user - , subq_22.listing__user AS user__listing__user - , subq_22.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_11.listings AS listings + subq_2.user AS user + , subq_13.listing__user AS user__listing__user + , subq_13.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_10.user - , subq_10.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__extract_quarter - , subq_9.ds__extract_month - , subq_9.ds__extract_day - , subq_9.ds__extract_dow - , subq_9.ds__extract_doy - , subq_9.created_at__day - , subq_9.created_at__week - , subq_9.created_at__month - , subq_9.created_at__quarter - , subq_9.created_at__year - , subq_9.created_at__extract_year - , subq_9.created_at__extract_quarter - , subq_9.created_at__extract_month - , subq_9.created_at__extract_day - , subq_9.created_at__extract_dow - , subq_9.created_at__extract_doy - , subq_9.listing__ds__day - , subq_9.listing__ds__week - , subq_9.listing__ds__month - , subq_9.listing__ds__quarter - , subq_9.listing__ds__year - , subq_9.listing__ds__extract_year - , subq_9.listing__ds__extract_quarter - , subq_9.listing__ds__extract_month - , subq_9.listing__ds__extract_day - , subq_9.listing__ds__extract_dow - , subq_9.listing__ds__extract_doy - , subq_9.listing__created_at__day - , subq_9.listing__created_at__week - , subq_9.listing__created_at__month - , subq_9.listing__created_at__quarter - , subq_9.listing__created_at__year - , subq_9.listing__created_at__extract_year - , subq_9.listing__created_at__extract_quarter - , subq_9.listing__created_at__extract_month - , subq_9.listing__created_at__extract_day - , subq_9.listing__created_at__extract_dow - , subq_9.listing__created_at__extract_doy - , subq_9.ds__day AS metric_time__day - , subq_9.ds__week AS metric_time__week - , subq_9.ds__month AS metric_time__month - , subq_9.ds__quarter AS metric_time__quarter - , subq_9.ds__year AS metric_time__year - , subq_9.ds__extract_year AS metric_time__extract_year - , subq_9.ds__extract_quarter AS metric_time__extract_quarter - , subq_9.ds__extract_month AS metric_time__extract_month - , subq_9.ds__extract_day AS metric_time__extract_day - , subq_9.ds__extract_dow AS metric_time__extract_dow - , subq_9.ds__extract_doy AS metric_time__extract_doy - , subq_9.listing - , subq_9.user - , subq_9.listing__user - , subq_9.country_latest - , subq_9.is_lux_latest - , subq_9.capacity_latest - , subq_9.listing__country_latest - , subq_9.listing__is_lux_latest - , subq_9.listing__capacity_latest - , subq_9.listings - , subq_9.largest_listing - , subq_9.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -161,141 +161,141 @@ 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_9 - ) subq_10 - ) subq_11 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] SELECT - subq_21.listing__user - , subq_21.listing__user__average_booking_value + subq_12.listing__user + , subq_12.listing__user__average_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_20.listing__user - , subq_20.average_booking_value AS listing__user__average_booking_value + subq_11.listing__user + , subq_11.average_booking_value AS listing__user__average_booking_value FROM ( -- Aggregate Measures SELECT - subq_19.listing__user - , AVG(subq_19.average_booking_value) AS average_booking_value + subq_10.listing__user + , AVG(subq_10.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__user'] SELECT - subq_18.listing__user - , subq_18.average_booking_value + subq_9.listing__user + , subq_9.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_14.listing AS listing - , subq_17.user AS listing__user - , subq_14.average_booking_value AS average_booking_value + subq_5.listing AS listing + , subq_8.user AS listing__user + , subq_5.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing'] SELECT - subq_13.listing - , subq_13.average_booking_value + subq_4.listing + , subq_4.average_booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -388,84 +388,84 @@ 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_12 - ) subq_13 - ) subq_14 + ) subq_3 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'user'] SELECT - subq_16.listing - , subq_16.user + subq_7.listing + , subq_7.user FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.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 @@ -526,23 +526,23 @@ 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_15 - ) subq_16 - ) subq_17 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_5.listing = subq_8.listing + ) subq_9 + ) subq_10 GROUP BY - subq_19.listing__user - ) subq_20 - ) subq_21 - ) subq_22 + subq_10.listing__user + ) subq_11 + ) subq_12 + ) subq_13 ON - subq_11.user = subq_22.listing__user - ) subq_23 - ) subq_24 + subq_2.user = subq_13.listing__user + ) subq_14 + ) subq_15 WHERE user__listing__user__average_booking_value > 1 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_group_by_has_local_entity_prefix__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_group_by_has_local_entity_prefix__plan0_optimized.sql index f2d9e26580..8a2de81699 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_group_by_has_local_entity_prefix__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_group_by_has_local_entity_prefix__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_50.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_39.listings AS listings + subq_32.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_21.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_39 + ) subq_21 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__user'] @@ -35,8 +35,8 @@ FROM ( bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY listings_latest_src_28000.user_id - ) subq_50 + ) subq_32 ON - subq_39.user = subq_50.listing__user -) subq_52 + subq_21.user = subq_32.listing__user +) subq_34 WHERE user__listing__user__average_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_multi_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_multi_hop__plan0.sql index 7deea353a9..3146c0bc2f 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_multi_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_multi_hop__plan0.sql @@ -1,76 +1,76 @@ -- Compute Metrics via Expressions SELECT - subq_40.third_hop_count + subq_22.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_39.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_21.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_38.third_hop_count + subq_20.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_37.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_37.third_hop_count + subq_19.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_19.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_36.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_36.third_hop_count + subq_18.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_18.third_hop_count FROM ( -- Join Standard Outputs SELECT - subq_20.customer_third_hop_id AS customer_third_hop_id - , subq_35.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id - , subq_35.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_20.third_hop_count AS third_hop_count + subq_2.customer_third_hop_id AS customer_third_hop_id + , subq_17.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_17.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_2.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_19.customer_third_hop_id - , subq_19.third_hop_count + subq_1.customer_third_hop_id + , subq_1.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - subq_18.third_hop_ds__day - , subq_18.third_hop_ds__week - , subq_18.third_hop_ds__month - , subq_18.third_hop_ds__quarter - , subq_18.third_hop_ds__year - , subq_18.third_hop_ds__extract_year - , subq_18.third_hop_ds__extract_quarter - , subq_18.third_hop_ds__extract_month - , subq_18.third_hop_ds__extract_day - , subq_18.third_hop_ds__extract_dow - , subq_18.third_hop_ds__extract_doy - , subq_18.customer_third_hop_id__third_hop_ds__day - , subq_18.customer_third_hop_id__third_hop_ds__week - , subq_18.customer_third_hop_id__third_hop_ds__month - , subq_18.customer_third_hop_id__third_hop_ds__quarter - , subq_18.customer_third_hop_id__third_hop_ds__year - , subq_18.customer_third_hop_id__third_hop_ds__extract_year - , subq_18.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_18.customer_third_hop_id__third_hop_ds__extract_month - , subq_18.customer_third_hop_id__third_hop_ds__extract_day - , subq_18.customer_third_hop_id__third_hop_ds__extract_dow - , subq_18.customer_third_hop_id__third_hop_ds__extract_doy - , subq_18.third_hop_ds__day AS metric_time__day - , subq_18.third_hop_ds__week AS metric_time__week - , subq_18.third_hop_ds__month AS metric_time__month - , subq_18.third_hop_ds__quarter AS metric_time__quarter - , subq_18.third_hop_ds__year AS metric_time__year - , subq_18.third_hop_ds__extract_year AS metric_time__extract_year - , subq_18.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_18.third_hop_ds__extract_month AS metric_time__extract_month - , subq_18.third_hop_ds__extract_day AS metric_time__extract_day - , subq_18.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_18.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_18.customer_third_hop_id - , subq_18.value - , subq_18.customer_third_hop_id__value - , subq_18.third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( -- Read Elements From Semantic Model 'third_hop_table' SELECT @@ -101,105 +101,105 @@ 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_18 - ) subq_19 - ) subq_20 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_34.account_id__customer_id__customer_third_hop_id - , subq_34.account_id__customer_id__customer_third_hop_id__txn_count + subq_16.account_id__customer_id__customer_third_hop_id + , subq_16.account_id__customer_id__customer_third_hop_id__txn_count FROM ( -- Compute Metrics via Expressions SELECT - subq_33.account_id__customer_id__customer_third_hop_id - , subq_33.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count + subq_15.account_id__customer_id__customer_third_hop_id + , subq_15.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count FROM ( -- Aggregate Measures SELECT - subq_32.account_id__customer_id__customer_third_hop_id - , SUM(subq_32.txn_count) AS txn_count + subq_14.account_id__customer_id__customer_third_hop_id + , SUM(subq_14.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] SELECT - subq_31.account_id__customer_id__customer_third_hop_id - , subq_31.txn_count + subq_13.account_id__customer_id__customer_third_hop_id + , subq_13.txn_count FROM ( -- Join Standard Outputs SELECT - subq_23.ds_partitioned__day AS ds_partitioned__day - , subq_30.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_23.account_id AS account_id - , subq_30.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id - , subq_23.txn_count AS txn_count + subq_5.ds_partitioned__day AS ds_partitioned__day + , subq_12.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_5.account_id AS account_id + , subq_12.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + , subq_5.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_22.ds_partitioned__day - , subq_22.account_id - , subq_22.txn_count + subq_4.ds_partitioned__day + , subq_4.account_id + , subq_4.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_21.ds_partitioned__day - , subq_21.ds_partitioned__week - , subq_21.ds_partitioned__month - , subq_21.ds_partitioned__quarter - , subq_21.ds_partitioned__year - , subq_21.ds_partitioned__extract_year - , subq_21.ds_partitioned__extract_quarter - , subq_21.ds_partitioned__extract_month - , subq_21.ds_partitioned__extract_day - , subq_21.ds_partitioned__extract_dow - , subq_21.ds_partitioned__extract_doy - , subq_21.ds__day - , subq_21.ds__week - , subq_21.ds__month - , subq_21.ds__quarter - , subq_21.ds__year - , subq_21.ds__extract_year - , subq_21.ds__extract_quarter - , subq_21.ds__extract_month - , subq_21.ds__extract_day - , subq_21.ds__extract_dow - , subq_21.ds__extract_doy - , subq_21.account_id__ds_partitioned__day - , subq_21.account_id__ds_partitioned__week - , subq_21.account_id__ds_partitioned__month - , subq_21.account_id__ds_partitioned__quarter - , subq_21.account_id__ds_partitioned__year - , subq_21.account_id__ds_partitioned__extract_year - , subq_21.account_id__ds_partitioned__extract_quarter - , subq_21.account_id__ds_partitioned__extract_month - , subq_21.account_id__ds_partitioned__extract_day - , subq_21.account_id__ds_partitioned__extract_dow - , subq_21.account_id__ds_partitioned__extract_doy - , subq_21.account_id__ds__day - , subq_21.account_id__ds__week - , subq_21.account_id__ds__month - , subq_21.account_id__ds__quarter - , subq_21.account_id__ds__year - , subq_21.account_id__ds__extract_year - , subq_21.account_id__ds__extract_quarter - , subq_21.account_id__ds__extract_month - , subq_21.account_id__ds__extract_day - , subq_21.account_id__ds__extract_dow - , subq_21.account_id__ds__extract_doy - , subq_21.ds__day AS metric_time__day - , subq_21.ds__week AS metric_time__week - , subq_21.ds__month AS metric_time__month - , subq_21.ds__quarter AS metric_time__quarter - , subq_21.ds__year AS metric_time__year - , subq_21.ds__extract_year AS metric_time__extract_year - , subq_21.ds__extract_quarter AS metric_time__extract_quarter - , subq_21.ds__extract_month AS metric_time__extract_month - , subq_21.ds__extract_day AS metric_time__extract_day - , subq_21.ds__extract_dow AS metric_time__extract_dow - , subq_21.ds__extract_doy AS metric_time__extract_doy - , subq_21.account_id - , subq_21.account_month - , subq_21.account_id__account_month - , subq_21.txn_count + 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.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.account_id__ds_partitioned__day + , subq_3.account_id__ds_partitioned__week + , subq_3.account_id__ds_partitioned__month + , subq_3.account_id__ds_partitioned__quarter + , subq_3.account_id__ds_partitioned__year + , subq_3.account_id__ds_partitioned__extract_year + , subq_3.account_id__ds_partitioned__extract_quarter + , subq_3.account_id__ds_partitioned__extract_month + , subq_3.account_id__ds_partitioned__extract_day + , subq_3.account_id__ds_partitioned__extract_dow + , subq_3.account_id__ds_partitioned__extract_doy + , subq_3.account_id__ds__day + , subq_3.account_id__ds__week + , subq_3.account_id__ds__month + , subq_3.account_id__ds__quarter + , subq_3.account_id__ds__year + , subq_3.account_id__ds__extract_year + , subq_3.account_id__ds__extract_quarter + , subq_3.account_id__ds__extract_month + , subq_3.account_id__ds__extract_day + , subq_3.account_id__ds__extract_dow + , subq_3.account_id__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_3.account_id + , subq_3.account_month + , subq_3.account_id__account_month + , subq_3.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -252,164 +252,164 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_3 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] SELECT - subq_29.ds_partitioned__day - , subq_29.account_id - , subq_29.customer_id__customer_third_hop_id + subq_11.ds_partitioned__day + , subq_11.account_id + , subq_11.customer_id__customer_third_hop_id FROM ( -- Join Standard Outputs SELECT - subq_25.ds_partitioned__day AS ds_partitioned__day - , subq_25.ds_partitioned__week AS ds_partitioned__week - , subq_25.ds_partitioned__month AS ds_partitioned__month - , subq_25.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_25.ds_partitioned__year AS ds_partitioned__year - , subq_25.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_25.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_25.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_25.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_25.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_25.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_25.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_25.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_25.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_25.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_25.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_25.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_25.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_25.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_25.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_25.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_25.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_25.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_25.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_25.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_25.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_25.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_25.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_25.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_25.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_25.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_25.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_25.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_25.metric_time__day AS metric_time__day - , subq_25.metric_time__week AS metric_time__week - , subq_25.metric_time__month AS metric_time__month - , subq_25.metric_time__quarter AS metric_time__quarter - , subq_25.metric_time__year AS metric_time__year - , subq_25.metric_time__extract_year AS metric_time__extract_year - , subq_25.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_25.metric_time__extract_month AS metric_time__extract_month - , subq_25.metric_time__extract_day AS metric_time__extract_day - , subq_25.metric_time__extract_dow AS metric_time__extract_dow - , subq_25.metric_time__extract_doy AS metric_time__extract_doy - , subq_28.acquired_ds__day AS customer_id__acquired_ds__day - , subq_28.acquired_ds__week AS customer_id__acquired_ds__week - , subq_28.acquired_ds__month AS customer_id__acquired_ds__month - , subq_28.acquired_ds__quarter AS customer_id__acquired_ds__quarter - , subq_28.acquired_ds__year AS customer_id__acquired_ds__year - , subq_28.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year - , subq_28.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter - , subq_28.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month - , subq_28.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day - , subq_28.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow - , subq_28.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy - , subq_28.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day - , subq_28.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week - , subq_28.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month - , subq_28.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter - , subq_28.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year - , subq_28.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year - , subq_28.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter - , subq_28.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month - , subq_28.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day - , subq_28.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow - , subq_28.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy - , subq_28.metric_time__day AS customer_id__metric_time__day - , subq_28.metric_time__week AS customer_id__metric_time__week - , subq_28.metric_time__month AS customer_id__metric_time__month - , subq_28.metric_time__quarter AS customer_id__metric_time__quarter - , subq_28.metric_time__year AS customer_id__metric_time__year - , subq_28.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_28.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_28.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_28.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_28.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_28.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_25.account_id AS account_id - , subq_25.customer_id AS customer_id - , subq_25.account_id__customer_id AS account_id__customer_id - , subq_25.bridge_account__account_id AS bridge_account__account_id - , subq_25.bridge_account__customer_id AS bridge_account__customer_id - , subq_28.customer_third_hop_id AS customer_id__customer_third_hop_id - , subq_28.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id - , subq_25.extra_dim AS extra_dim - , subq_25.account_id__extra_dim AS account_id__extra_dim - , subq_25.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_28.country AS customer_id__country - , subq_28.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country - , subq_25.account_customer_combos AS account_customer_combos + subq_7.ds_partitioned__day AS ds_partitioned__day + , subq_7.ds_partitioned__week AS ds_partitioned__week + , subq_7.ds_partitioned__month AS ds_partitioned__month + , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_7.ds_partitioned__year AS ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_7.metric_time__day AS metric_time__day + , subq_7.metric_time__week AS metric_time__week + , subq_7.metric_time__month AS metric_time__month + , subq_7.metric_time__quarter AS metric_time__quarter + , subq_7.metric_time__year AS metric_time__year + , subq_7.metric_time__extract_year AS metric_time__extract_year + , subq_7.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_7.metric_time__extract_month AS metric_time__extract_month + , subq_7.metric_time__extract_day AS metric_time__extract_day + , subq_7.metric_time__extract_dow AS metric_time__extract_dow + , subq_7.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.acquired_ds__day AS customer_id__acquired_ds__day + , subq_10.acquired_ds__week AS customer_id__acquired_ds__week + , subq_10.acquired_ds__month AS customer_id__acquired_ds__month + , subq_10.acquired_ds__quarter AS customer_id__acquired_ds__quarter + , subq_10.acquired_ds__year AS customer_id__acquired_ds__year + , subq_10.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year + , subq_10.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter + , subq_10.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month + , subq_10.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day + , subq_10.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow + , subq_10.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy + , subq_10.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day + , subq_10.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week + , subq_10.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month + , subq_10.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter + , subq_10.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year + , subq_10.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year + , subq_10.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter + , subq_10.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month + , subq_10.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day + , subq_10.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow + , subq_10.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy + , subq_10.metric_time__day AS customer_id__metric_time__day + , subq_10.metric_time__week AS customer_id__metric_time__week + , subq_10.metric_time__month AS customer_id__metric_time__month + , subq_10.metric_time__quarter AS customer_id__metric_time__quarter + , subq_10.metric_time__year AS customer_id__metric_time__year + , subq_10.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_10.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_10.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_10.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_10.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_10.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_7.account_id AS account_id + , subq_7.customer_id AS customer_id + , subq_7.account_id__customer_id AS account_id__customer_id + , subq_7.bridge_account__account_id AS bridge_account__account_id + , subq_7.bridge_account__customer_id AS bridge_account__customer_id + , subq_10.customer_third_hop_id AS customer_id__customer_third_hop_id + , subq_10.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id + , subq_7.extra_dim AS extra_dim + , subq_7.account_id__extra_dim AS account_id__extra_dim + , subq_7.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_10.country AS customer_id__country + , subq_10.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country + , subq_7.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.account_id__ds_partitioned__day - , subq_24.account_id__ds_partitioned__week - , subq_24.account_id__ds_partitioned__month - , subq_24.account_id__ds_partitioned__quarter - , subq_24.account_id__ds_partitioned__year - , subq_24.account_id__ds_partitioned__extract_year - , subq_24.account_id__ds_partitioned__extract_quarter - , subq_24.account_id__ds_partitioned__extract_month - , subq_24.account_id__ds_partitioned__extract_day - , subq_24.account_id__ds_partitioned__extract_dow - , subq_24.account_id__ds_partitioned__extract_doy - , subq_24.bridge_account__ds_partitioned__day - , subq_24.bridge_account__ds_partitioned__week - , subq_24.bridge_account__ds_partitioned__month - , subq_24.bridge_account__ds_partitioned__quarter - , subq_24.bridge_account__ds_partitioned__year - , subq_24.bridge_account__ds_partitioned__extract_year - , subq_24.bridge_account__ds_partitioned__extract_quarter - , subq_24.bridge_account__ds_partitioned__extract_month - , subq_24.bridge_account__ds_partitioned__extract_day - , subq_24.bridge_account__ds_partitioned__extract_dow - , subq_24.bridge_account__ds_partitioned__extract_doy - , subq_24.ds_partitioned__day AS metric_time__day - , subq_24.ds_partitioned__week AS metric_time__week - , subq_24.ds_partitioned__month AS metric_time__month - , subq_24.ds_partitioned__quarter AS metric_time__quarter - , subq_24.ds_partitioned__year AS metric_time__year - , subq_24.ds_partitioned__extract_year AS metric_time__extract_year - , subq_24.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_24.ds_partitioned__extract_month AS metric_time__extract_month - , subq_24.ds_partitioned__extract_day AS metric_time__extract_day - , subq_24.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_24.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_24.account_id - , subq_24.customer_id - , subq_24.account_id__customer_id - , subq_24.bridge_account__account_id - , subq_24.bridge_account__customer_id - , subq_24.extra_dim - , subq_24.account_id__extra_dim - , subq_24.bridge_account__extra_dim - , subq_24.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_6.account_id__ds_partitioned__week + , subq_6.account_id__ds_partitioned__month + , subq_6.account_id__ds_partitioned__quarter + , subq_6.account_id__ds_partitioned__year + , subq_6.account_id__ds_partitioned__extract_year + , subq_6.account_id__ds_partitioned__extract_quarter + , subq_6.account_id__ds_partitioned__extract_month + , subq_6.account_id__ds_partitioned__extract_day + , subq_6.account_id__ds_partitioned__extract_dow + , subq_6.account_id__ds_partitioned__extract_doy + , subq_6.bridge_account__ds_partitioned__day + , subq_6.bridge_account__ds_partitioned__week + , subq_6.bridge_account__ds_partitioned__month + , subq_6.bridge_account__ds_partitioned__quarter + , subq_6.bridge_account__ds_partitioned__year + , subq_6.bridge_account__ds_partitioned__extract_year + , subq_6.bridge_account__ds_partitioned__extract_quarter + , subq_6.bridge_account__ds_partitioned__extract_month + , subq_6.bridge_account__ds_partitioned__extract_day + , subq_6.bridge_account__ds_partitioned__extract_dow + , subq_6.bridge_account__ds_partitioned__extract_doy + , subq_6.ds_partitioned__day AS metric_time__day + , subq_6.ds_partitioned__week AS metric_time__week + , subq_6.ds_partitioned__month AS metric_time__month + , subq_6.ds_partitioned__quarter AS metric_time__quarter + , subq_6.ds_partitioned__year AS metric_time__year + , subq_6.ds_partitioned__extract_year AS metric_time__extract_year + , subq_6.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_6.ds_partitioned__extract_month AS metric_time__extract_month + , subq_6.ds_partitioned__extract_day AS metric_time__extract_day + , subq_6.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_6.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_6.account_id + , subq_6.customer_id + , subq_6.account_id__customer_id + , subq_6.bridge_account__account_id + , subq_6.bridge_account__customer_id + , subq_6.extra_dim + , subq_6.account_id__extra_dim + , subq_6.bridge_account__extra_dim + , subq_6.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -456,8 +456,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_24 - ) subq_25 + ) subq_6 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'country', @@ -513,112 +513,112 @@ FROM ( -- 'customer_third_hop_id__customer_id', -- ] SELECT - subq_27.acquired_ds__day - , subq_27.acquired_ds__week - , subq_27.acquired_ds__month - , subq_27.acquired_ds__quarter - , subq_27.acquired_ds__year - , subq_27.acquired_ds__extract_year - , subq_27.acquired_ds__extract_quarter - , subq_27.acquired_ds__extract_month - , subq_27.acquired_ds__extract_day - , subq_27.acquired_ds__extract_dow - , subq_27.acquired_ds__extract_doy - , subq_27.customer_id__acquired_ds__day - , subq_27.customer_id__acquired_ds__week - , subq_27.customer_id__acquired_ds__month - , subq_27.customer_id__acquired_ds__quarter - , subq_27.customer_id__acquired_ds__year - , subq_27.customer_id__acquired_ds__extract_year - , subq_27.customer_id__acquired_ds__extract_quarter - , subq_27.customer_id__acquired_ds__extract_month - , subq_27.customer_id__acquired_ds__extract_day - , subq_27.customer_id__acquired_ds__extract_dow - , subq_27.customer_id__acquired_ds__extract_doy - , subq_27.customer_third_hop_id__acquired_ds__day - , subq_27.customer_third_hop_id__acquired_ds__week - , subq_27.customer_third_hop_id__acquired_ds__month - , subq_27.customer_third_hop_id__acquired_ds__quarter - , subq_27.customer_third_hop_id__acquired_ds__year - , subq_27.customer_third_hop_id__acquired_ds__extract_year - , subq_27.customer_third_hop_id__acquired_ds__extract_quarter - , subq_27.customer_third_hop_id__acquired_ds__extract_month - , subq_27.customer_third_hop_id__acquired_ds__extract_day - , subq_27.customer_third_hop_id__acquired_ds__extract_dow - , subq_27.customer_third_hop_id__acquired_ds__extract_doy - , subq_27.metric_time__day - , subq_27.metric_time__week - , subq_27.metric_time__month - , subq_27.metric_time__quarter - , subq_27.metric_time__year - , subq_27.metric_time__extract_year - , subq_27.metric_time__extract_quarter - , subq_27.metric_time__extract_month - , subq_27.metric_time__extract_day - , subq_27.metric_time__extract_dow - , subq_27.metric_time__extract_doy - , subq_27.customer_id - , subq_27.customer_third_hop_id - , subq_27.customer_id__customer_third_hop_id - , subq_27.customer_third_hop_id__customer_id - , subq_27.country - , subq_27.customer_id__country - , subq_27.customer_third_hop_id__country + subq_9.acquired_ds__day + , subq_9.acquired_ds__week + , subq_9.acquired_ds__month + , subq_9.acquired_ds__quarter + , subq_9.acquired_ds__year + , subq_9.acquired_ds__extract_year + , subq_9.acquired_ds__extract_quarter + , subq_9.acquired_ds__extract_month + , subq_9.acquired_ds__extract_day + , subq_9.acquired_ds__extract_dow + , subq_9.acquired_ds__extract_doy + , subq_9.customer_id__acquired_ds__day + , subq_9.customer_id__acquired_ds__week + , subq_9.customer_id__acquired_ds__month + , subq_9.customer_id__acquired_ds__quarter + , subq_9.customer_id__acquired_ds__year + , subq_9.customer_id__acquired_ds__extract_year + , subq_9.customer_id__acquired_ds__extract_quarter + , subq_9.customer_id__acquired_ds__extract_month + , subq_9.customer_id__acquired_ds__extract_day + , subq_9.customer_id__acquired_ds__extract_dow + , subq_9.customer_id__acquired_ds__extract_doy + , subq_9.customer_third_hop_id__acquired_ds__day + , subq_9.customer_third_hop_id__acquired_ds__week + , subq_9.customer_third_hop_id__acquired_ds__month + , subq_9.customer_third_hop_id__acquired_ds__quarter + , subq_9.customer_third_hop_id__acquired_ds__year + , subq_9.customer_third_hop_id__acquired_ds__extract_year + , subq_9.customer_third_hop_id__acquired_ds__extract_quarter + , subq_9.customer_third_hop_id__acquired_ds__extract_month + , subq_9.customer_third_hop_id__acquired_ds__extract_day + , subq_9.customer_third_hop_id__acquired_ds__extract_dow + , subq_9.customer_third_hop_id__acquired_ds__extract_doy + , subq_9.metric_time__day + , subq_9.metric_time__week + , subq_9.metric_time__month + , subq_9.metric_time__quarter + , subq_9.metric_time__year + , subq_9.metric_time__extract_year + , subq_9.metric_time__extract_quarter + , subq_9.metric_time__extract_month + , subq_9.metric_time__extract_day + , subq_9.metric_time__extract_dow + , subq_9.metric_time__extract_doy + , subq_9.customer_id + , subq_9.customer_third_hop_id + , subq_9.customer_id__customer_third_hop_id + , subq_9.customer_third_hop_id__customer_id + , subq_9.country + , subq_9.customer_id__country + , subq_9.customer_third_hop_id__country FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - subq_26.acquired_ds__day - , subq_26.acquired_ds__week - , subq_26.acquired_ds__month - , subq_26.acquired_ds__quarter - , subq_26.acquired_ds__year - , subq_26.acquired_ds__extract_year - , subq_26.acquired_ds__extract_quarter - , subq_26.acquired_ds__extract_month - , subq_26.acquired_ds__extract_day - , subq_26.acquired_ds__extract_dow - , subq_26.acquired_ds__extract_doy - , subq_26.customer_id__acquired_ds__day - , subq_26.customer_id__acquired_ds__week - , subq_26.customer_id__acquired_ds__month - , subq_26.customer_id__acquired_ds__quarter - , subq_26.customer_id__acquired_ds__year - , subq_26.customer_id__acquired_ds__extract_year - , subq_26.customer_id__acquired_ds__extract_quarter - , subq_26.customer_id__acquired_ds__extract_month - , subq_26.customer_id__acquired_ds__extract_day - , subq_26.customer_id__acquired_ds__extract_dow - , subq_26.customer_id__acquired_ds__extract_doy - , subq_26.customer_third_hop_id__acquired_ds__day - , subq_26.customer_third_hop_id__acquired_ds__week - , subq_26.customer_third_hop_id__acquired_ds__month - , subq_26.customer_third_hop_id__acquired_ds__quarter - , subq_26.customer_third_hop_id__acquired_ds__year - , subq_26.customer_third_hop_id__acquired_ds__extract_year - , subq_26.customer_third_hop_id__acquired_ds__extract_quarter - , subq_26.customer_third_hop_id__acquired_ds__extract_month - , subq_26.customer_third_hop_id__acquired_ds__extract_day - , subq_26.customer_third_hop_id__acquired_ds__extract_dow - , subq_26.customer_third_hop_id__acquired_ds__extract_doy - , subq_26.acquired_ds__day AS metric_time__day - , subq_26.acquired_ds__week AS metric_time__week - , subq_26.acquired_ds__month AS metric_time__month - , subq_26.acquired_ds__quarter AS metric_time__quarter - , subq_26.acquired_ds__year AS metric_time__year - , subq_26.acquired_ds__extract_year AS metric_time__extract_year - , subq_26.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_26.acquired_ds__extract_month AS metric_time__extract_month - , subq_26.acquired_ds__extract_day AS metric_time__extract_day - , subq_26.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_26.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_26.customer_id - , subq_26.customer_third_hop_id - , subq_26.customer_id__customer_third_hop_id - , subq_26.customer_third_hop_id__customer_id - , subq_26.country - , subq_26.customer_id__country - , subq_26.customer_third_hop_id__country - , subq_26.customers_with_other_data + subq_8.acquired_ds__day + , subq_8.acquired_ds__week + , subq_8.acquired_ds__month + , subq_8.acquired_ds__quarter + , subq_8.acquired_ds__year + , subq_8.acquired_ds__extract_year + , subq_8.acquired_ds__extract_quarter + , subq_8.acquired_ds__extract_month + , subq_8.acquired_ds__extract_day + , subq_8.acquired_ds__extract_dow + , subq_8.acquired_ds__extract_doy + , subq_8.customer_id__acquired_ds__day + , subq_8.customer_id__acquired_ds__week + , subq_8.customer_id__acquired_ds__month + , subq_8.customer_id__acquired_ds__quarter + , subq_8.customer_id__acquired_ds__year + , subq_8.customer_id__acquired_ds__extract_year + , subq_8.customer_id__acquired_ds__extract_quarter + , subq_8.customer_id__acquired_ds__extract_month + , subq_8.customer_id__acquired_ds__extract_day + , subq_8.customer_id__acquired_ds__extract_dow + , subq_8.customer_id__acquired_ds__extract_doy + , subq_8.customer_third_hop_id__acquired_ds__day + , subq_8.customer_third_hop_id__acquired_ds__week + , subq_8.customer_third_hop_id__acquired_ds__month + , subq_8.customer_third_hop_id__acquired_ds__quarter + , subq_8.customer_third_hop_id__acquired_ds__year + , subq_8.customer_third_hop_id__acquired_ds__extract_year + , subq_8.customer_third_hop_id__acquired_ds__extract_quarter + , subq_8.customer_third_hop_id__acquired_ds__extract_month + , subq_8.customer_third_hop_id__acquired_ds__extract_day + , subq_8.customer_third_hop_id__acquired_ds__extract_dow + , subq_8.customer_third_hop_id__acquired_ds__extract_doy + , subq_8.acquired_ds__day AS metric_time__day + , subq_8.acquired_ds__week AS metric_time__week + , subq_8.acquired_ds__month AS metric_time__month + , subq_8.acquired_ds__quarter AS metric_time__quarter + , subq_8.acquired_ds__year AS metric_time__year + , subq_8.acquired_ds__extract_year AS metric_time__extract_year + , subq_8.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_8.acquired_ds__extract_month AS metric_time__extract_month + , subq_8.acquired_ds__extract_day AS metric_time__extract_day + , subq_8.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_8.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_8.customer_id + , subq_8.customer_third_hop_id + , subq_8.customer_id__customer_third_hop_id + , subq_8.customer_third_hop_id__customer_id + , subq_8.country + , subq_8.customer_id__country + , subq_8.customer_third_hop_id__country + , subq_8.customers_with_other_data FROM ( -- Read Elements From Semantic Model 'customer_other_data' SELECT @@ -664,31 +664,31 @@ 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_26 - ) subq_27 - ) subq_28 + ) subq_8 + ) subq_9 + ) subq_10 ON - subq_25.customer_id = subq_28.customer_id - ) subq_29 - ) subq_30 + subq_7.customer_id = subq_10.customer_id + ) subq_11 + ) subq_12 ON ( - subq_23.account_id = subq_30.account_id + subq_5.account_id = subq_12.account_id ) AND ( - subq_23.ds_partitioned__day = subq_30.ds_partitioned__day + subq_5.ds_partitioned__day = subq_12.ds_partitioned__day ) - ) subq_31 - ) subq_32 + ) subq_13 + ) subq_14 GROUP BY - subq_32.account_id__customer_id__customer_third_hop_id - ) subq_33 - ) subq_34 - ) subq_35 + subq_14.account_id__customer_id__customer_third_hop_id + ) subq_15 + ) subq_16 + ) subq_17 ON - subq_20.customer_third_hop_id = subq_35.account_id__customer_id__customer_third_hop_id - ) subq_36 - ) subq_37 + subq_2.customer_third_hop_id = subq_17.account_id__customer_id__customer_third_hop_id + ) subq_18 + ) subq_19 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 - ) subq_38 - ) subq_39 -) subq_40 + ) subq_20 + ) subq_21 +) subq_22 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_multi_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_multi_hop__plan0_optimized.sql index bf66de5356..97117da92a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_multi_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_multi_hop__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_76.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + subq_40.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count , 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 ( @@ -18,7 +18,7 @@ FROM ( -- Compute Metrics via Expressions -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_71.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + subq_35.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id , SUM(account_month_txns_src_22000.txn_count) AS account_id__customer_id__customer_third_hop_id__txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -33,17 +33,17 @@ FROM ( ***************************.customer_other_data customer_other_data_src_22000 ON bridge_table_src_22000.customer_id = customer_other_data_src_22000.customer_id - ) subq_71 + ) subq_35 ON ( - account_month_txns_src_22000.account_id = subq_71.account_id + account_month_txns_src_22000.account_id = subq_35.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_71.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_35.ds_partitioned__day ) GROUP BY - subq_71.customer_id__customer_third_hop_id - ) subq_76 + subq_35.customer_id__customer_third_hop_id + ) subq_40 ON - third_hop_table_src_22000.customer_third_hop_id = subq_76.account_id__customer_id__customer_third_hop_id -) subq_78 + third_hop_table_src_22000.customer_third_hop_id = subq_40.account_id__customer_id__customer_third_hop_id +) subq_42 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_single_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_single_hop__plan0.sql index 7e727a5e96..c6d158e947 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_single_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_single_hop__plan0.sql @@ -1,76 +1,76 @@ -- Compute Metrics via Expressions SELECT - subq_25.third_hop_count + subq_16.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_24.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_15.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_23.third_hop_count + subq_14.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_22.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_22.third_hop_count + subq_13.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_13.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_21.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_21.third_hop_count + subq_12.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_12.third_hop_count FROM ( -- Join Standard Outputs SELECT - 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 + subq_2.customer_third_hop_id AS customer_third_hop_id + , subq_11.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_11.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_2.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_10.customer_third_hop_id - , subq_10.third_hop_count + subq_1.customer_third_hop_id + , subq_1.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - 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 + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.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_9 - ) subq_10 - ) subq_11 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_19.customer_id__customer_third_hop_id - , subq_19.customer_id__customer_third_hop_id__paraguayan_customers + subq_10.customer_id__customer_third_hop_id + , subq_10.customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Compute Metrics via Expressions SELECT - subq_18.customer_id__customer_third_hop_id - , subq_18.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_9.customer_id__customer_third_hop_id + , subq_9.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Aggregate Measures SELECT - subq_17.customer_id__customer_third_hop_id - , SUM(subq_17.customers_with_other_data) AS customers_with_other_data + subq_8.customer_id__customer_third_hop_id + , SUM(subq_8.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_16.customer_id__customer_third_hop_id - , subq_16.customers_with_other_data + subq_7.customer_id__customer_third_hop_id + , subq_7.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_15.customer_id__customer_third_hop_id - , subq_15.customer_id__country - , subq_15.customers_with_other_data + subq_6.customer_id__customer_third_hop_id + , subq_6.customer_id__country + , subq_6.customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT - subq_14.customer_id__customer_third_hop_id - , subq_14.customer_id__country - , subq_14.customers_with_other_data + subq_5.customer_id__customer_third_hop_id + , subq_5.customer_id__country + , subq_5.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - 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 + subq_4.acquired_ds__day + , subq_4.acquired_ds__week + , subq_4.acquired_ds__month + , subq_4.acquired_ds__quarter + , subq_4.acquired_ds__year + , subq_4.acquired_ds__extract_year + , subq_4.acquired_ds__extract_quarter + , subq_4.acquired_ds__extract_month + , subq_4.acquired_ds__extract_day + , subq_4.acquired_ds__extract_dow + , subq_4.acquired_ds__extract_doy + , subq_4.customer_id__acquired_ds__day + , subq_4.customer_id__acquired_ds__week + , subq_4.customer_id__acquired_ds__month + , subq_4.customer_id__acquired_ds__quarter + , subq_4.customer_id__acquired_ds__year + , subq_4.customer_id__acquired_ds__extract_year + , subq_4.customer_id__acquired_ds__extract_quarter + , subq_4.customer_id__acquired_ds__extract_month + , subq_4.customer_id__acquired_ds__extract_day + , subq_4.customer_id__acquired_ds__extract_dow + , subq_4.customer_id__acquired_ds__extract_doy + , subq_4.customer_third_hop_id__acquired_ds__day + , subq_4.customer_third_hop_id__acquired_ds__week + , subq_4.customer_third_hop_id__acquired_ds__month + , subq_4.customer_third_hop_id__acquired_ds__quarter + , subq_4.customer_third_hop_id__acquired_ds__year + , subq_4.customer_third_hop_id__acquired_ds__extract_year + , subq_4.customer_third_hop_id__acquired_ds__extract_quarter + , subq_4.customer_third_hop_id__acquired_ds__extract_month + , subq_4.customer_third_hop_id__acquired_ds__extract_day + , subq_4.customer_third_hop_id__acquired_ds__extract_dow + , subq_4.customer_third_hop_id__acquired_ds__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.customer_id + , subq_4.customer_third_hop_id + , subq_4.customer_id__customer_third_hop_id + , subq_4.customer_third_hop_id__customer_id + , subq_4.country + , subq_4.customer_id__country + , subq_4.customer_third_hop_id__country + , subq_4.customers_with_other_data FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - 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 + subq_3.acquired_ds__day + , subq_3.acquired_ds__week + , subq_3.acquired_ds__month + , subq_3.acquired_ds__quarter + , subq_3.acquired_ds__year + , subq_3.acquired_ds__extract_year + , subq_3.acquired_ds__extract_quarter + , subq_3.acquired_ds__extract_month + , subq_3.acquired_ds__extract_day + , subq_3.acquired_ds__extract_dow + , subq_3.acquired_ds__extract_doy + , subq_3.customer_id__acquired_ds__day + , subq_3.customer_id__acquired_ds__week + , subq_3.customer_id__acquired_ds__month + , subq_3.customer_id__acquired_ds__quarter + , subq_3.customer_id__acquired_ds__year + , subq_3.customer_id__acquired_ds__extract_year + , subq_3.customer_id__acquired_ds__extract_quarter + , subq_3.customer_id__acquired_ds__extract_month + , subq_3.customer_id__acquired_ds__extract_day + , subq_3.customer_id__acquired_ds__extract_dow + , subq_3.customer_id__acquired_ds__extract_doy + , subq_3.customer_third_hop_id__acquired_ds__day + , subq_3.customer_third_hop_id__acquired_ds__week + , subq_3.customer_third_hop_id__acquired_ds__month + , subq_3.customer_third_hop_id__acquired_ds__quarter + , subq_3.customer_third_hop_id__acquired_ds__year + , subq_3.customer_third_hop_id__acquired_ds__extract_year + , subq_3.customer_third_hop_id__acquired_ds__extract_quarter + , subq_3.customer_third_hop_id__acquired_ds__extract_month + , subq_3.customer_third_hop_id__acquired_ds__extract_day + , subq_3.customer_third_hop_id__acquired_ds__extract_dow + , subq_3.customer_third_hop_id__acquired_ds__extract_doy + , subq_3.acquired_ds__day AS metric_time__day + , subq_3.acquired_ds__week AS metric_time__week + , subq_3.acquired_ds__month AS metric_time__month + , subq_3.acquired_ds__quarter AS metric_time__quarter + , subq_3.acquired_ds__year AS metric_time__year + , subq_3.acquired_ds__extract_year AS metric_time__extract_year + , subq_3.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_3.acquired_ds__extract_month AS metric_time__extract_month + , subq_3.acquired_ds__extract_day AS metric_time__extract_day + , subq_3.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_3.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_3.customer_id + , subq_3.customer_third_hop_id + , subq_3.customer_id__customer_third_hop_id + , subq_3.customer_third_hop_id__customer_id + , subq_3.country + , subq_3.customer_id__country + , subq_3.customer_third_hop_id__country + , subq_3.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_12 - ) subq_13 + ) subq_3 + ) subq_4 WHERE customer_id__country = 'paraguay' - ) subq_14 - ) subq_15 + ) subq_5 + ) subq_6 WHERE customer_id__country = 'paraguay' - ) subq_16 - ) subq_17 + ) subq_7 + ) subq_8 GROUP BY - subq_17.customer_id__customer_third_hop_id - ) subq_18 - ) subq_19 - ) subq_20 + subq_8.customer_id__customer_third_hop_id + ) subq_9 + ) subq_10 + ) subq_11 ON - subq_11.customer_third_hop_id = subq_20.customer_id__customer_third_hop_id - ) subq_21 - ) subq_22 + subq_2.customer_third_hop_id = subq_11.customer_id__customer_third_hop_id + ) subq_12 + ) subq_13 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_23 - ) subq_24 -) subq_25 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_single_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_single_hop__plan0_optimized.sql index 0fd2bf1820..b73c99c9a9 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_single_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/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_46.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_28.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_39 + ) subq_21 WHERE customer_id__country = 'paraguay' - ) subq_41 + ) subq_23 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_46 + ) subq_28 ON - third_hop_table_src_22000.customer_third_hop_id = subq_46.customer_id__customer_third_hop_id -) subq_48 + third_hop_table_src_22000.customer_third_hop_id = subq_28.customer_id__customer_third_hop_id +) subq_30 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_filtered_by_itself__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_filtered_by_itself__plan0.sql index 732f693611..c22561e2a0 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_filtered_by_itself__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_filtered_by_itself__plan0.sql @@ -1,136 +1,136 @@ -- Compute Metrics via Expressions SELECT - subq_17.bookers + subq_13.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_16.bookers) AS bookers + COUNT(DISTINCT subq_12.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_15.bookers + subq_11.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_14.listing__bookers - , subq_14.bookers + subq_10.listing__bookers + , subq_10.bookers FROM ( -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_13.listing__bookers - , subq_13.bookers + subq_9.listing__bookers + , subq_9.bookers FROM ( -- Join Standard Outputs SELECT - subq_6.listing AS listing - , subq_12.listing__bookers AS listing__bookers - , subq_6.bookers AS bookers + subq_2.listing AS listing + , subq_8.listing__bookers AS listing__bookers + , subq_2.bookers AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_5.listing - , subq_5.bookers + subq_1.listing + , subq_1.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -223,130 +223,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookers'] SELECT - subq_11.listing - , subq_11.listing__bookers + subq_7.listing + , subq_7.listing__bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookers AS listing__bookers + subq_6.listing + , subq_6.bookers AS listing__bookers FROM ( -- Aggregate Measures SELECT - subq_9.listing - , COUNT(DISTINCT subq_9.bookers) AS bookers + subq_5.listing + , COUNT(DISTINCT subq_5.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_8.listing - , subq_8.bookers + subq_4.listing + , subq_4.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -439,19 +439,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.listing - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookers > 1.00 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_filtered_by_itself__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_filtered_by_itself__plan0_optimized.sql index e5c7db19a1..fc6f75f09e 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_filtered_by_itself__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_filtered_by_itself__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_30.listing__bookers AS listing__bookers - , subq_24.bookers AS bookers + subq_22.listing__bookers AS listing__bookers + , subq_16.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookers > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_with_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_with_metric_in_where_filter__plan0.sql index aed5a00406..35bfbe44c8 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_with_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_with_metric_in_where_filter__plan0.sql @@ -1,112 +1,112 @@ -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day - , subq_17.listings AS active_listings + subq_13.metric_time__day + , subq_13.listings AS active_listings FROM ( -- Aggregate Measures SELECT - subq_16.metric_time__day - , SUM(subq_16.listings) AS listings + subq_12.metric_time__day + , SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day'] SELECT - subq_15.metric_time__day - , subq_15.listings + subq_11.metric_time__day + , subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.metric_time__day - , subq_14.listing__bookings - , subq_14.listings + subq_10.metric_time__day + , subq_10.listing__bookings + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_13.metric_time__day - , subq_13.listing__bookings - , subq_13.listings + subq_9.metric_time__day + , subq_9.listing__bookings + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.metric_time__day AS metric_time__day - , subq_6.listing AS listing - , subq_12.listing__bookings AS listing__bookings - , subq_6.listings AS listings + subq_2.metric_time__day AS metric_time__day + , subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] SELECT - subq_5.metric_time__day - , subq_5.listing - , subq_5.listings + subq_1.metric_time__day + , subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -167,130 +167,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_11.listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing - , SUM(subq_9.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_8.listing - , subq_8.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -383,21 +383,21 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.listing - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookings > 2 - ) subq_15 - ) subq_16 + ) subq_11 + ) subq_12 GROUP BY - subq_16.metric_time__day -) subq_17 + subq_12.metric_time__day +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_with_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_with_metric_in_where_filter__plan0_optimized.sql index a43cba6c94..21fd1f7db3 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_with_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_with_metric_in_where_filter__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_24.metric_time__day AS metric_time__day - , subq_30.listing__bookings AS listing__bookings - , subq_24.listings AS listings + subq_16.metric_time__day AS metric_time__day + , subq_22.listing__bookings AS listing__bookings + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -21,7 +21,7 @@ FROM ( , listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -37,13 +37,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_27 + ) subq_19 GROUP BY listing - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookings > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_cumulative_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_cumulative_metric_in_where_filter__plan0.sql index 194662f5a6..5e05e63f8a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_cumulative_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_cumulative_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_17.listings + subq_13.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_16.listings) AS listings + SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_15.listings + subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.user__revenue_all_time - , subq_14.listings + subq_10.user__revenue_all_time + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_13.user__revenue_all_time - , subq_13.listings + subq_9.user__revenue_all_time + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.user AS user - , subq_12.user__revenue_all_time AS user__revenue_all_time - , subq_6.listings AS listings + subq_2.user AS user + , subq_8.user__revenue_all_time AS user__revenue_all_time + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_5.user - , subq_5.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,68 +160,68 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user', 'user__revenue_all_time'] SELECT - subq_11.user - , subq_11.user__revenue_all_time + subq_7.user + , subq_7.user__revenue_all_time FROM ( -- Compute Metrics via Expressions SELECT - subq_10.user - , subq_10.txn_revenue AS user__revenue_all_time + subq_6.user + , subq_6.txn_revenue AS user__revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_9.user - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_5.user + , SUM(subq_5.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'user'] SELECT - subq_8.user - , subq_8.txn_revenue + subq_4.user + , subq_4.txn_revenue FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.revenue_instance__ds__day - , subq_7.revenue_instance__ds__week - , subq_7.revenue_instance__ds__month - , subq_7.revenue_instance__ds__quarter - , subq_7.revenue_instance__ds__year - , subq_7.revenue_instance__ds__extract_year - , subq_7.revenue_instance__ds__extract_quarter - , subq_7.revenue_instance__ds__extract_month - , subq_7.revenue_instance__ds__extract_day - , subq_7.revenue_instance__ds__extract_dow - , subq_7.revenue_instance__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.revenue_instance__user - , subq_7.txn_revenue + 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.revenue_instance__ds__day + , subq_3.revenue_instance__ds__week + , subq_3.revenue_instance__ds__month + , subq_3.revenue_instance__ds__quarter + , subq_3.revenue_instance__ds__year + , subq_3.revenue_instance__ds__extract_year + , subq_3.revenue_instance__ds__extract_quarter + , subq_3.revenue_instance__ds__extract_month + , subq_3.revenue_instance__ds__extract_day + , subq_3.revenue_instance__ds__extract_dow + , subq_3.revenue_instance__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_3.user + , subq_3.revenue_instance__user + , subq_3.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -251,19 +251,19 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.user - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.user + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.user = subq_12.user - ) subq_13 - ) subq_14 + subq_2.user = subq_8.user + ) subq_9 + ) subq_10 WHERE user__revenue_all_time > 1 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql index 4f006f13ed..2b782589e8 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_30.user__revenue_all_time AS user__revenue_all_time - , subq_24.listings AS listings + subq_22.user__revenue_all_time AS user__revenue_all_time + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_revenue revenue_src_28000 GROUP BY user_id - ) subq_30 + ) subq_22 ON - subq_24.user = subq_30.user -) subq_32 + subq_16.user = subq_22.user +) subq_24 WHERE user__revenue_all_time > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_derived_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_derived_metric_in_where_filter__plan0.sql index a1bf4deca0..b4b77786c8 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_derived_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_derived_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_31.listings + subq_20.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_30.listings) AS listings + SUM(subq_19.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_29.listings + subq_18.listings FROM ( -- Constrain Output with WHERE SELECT - subq_28.listing__views_times_booking_value - , subq_28.listings + subq_17.listing__views_times_booking_value + , subq_17.listings FROM ( -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_27.listing__views_times_booking_value - , subq_27.listings + subq_16.listing__views_times_booking_value + , subq_16.listings FROM ( -- Join Standard Outputs SELECT - subq_13.listing AS listing - , subq_26.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_13.listings AS listings + subq_2.listing AS listing + , subq_15.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_12.listing - , subq_12.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,141 +160,141 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] SELECT - subq_25.listing - , subq_25.listing__views_times_booking_value + subq_14.listing + , subq_14.listing__views_times_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_24.listing + subq_13.listing , booking_value * views AS listing__views_times_booking_value FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.listing, subq_23.listing) AS listing - , MAX(subq_18.booking_value) AS booking_value - , MAX(subq_23.views) AS views + COALESCE(subq_7.listing, subq_12.listing) AS listing + , MAX(subq_7.booking_value) AS booking_value + , MAX(subq_12.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_17.listing - , subq_17.booking_value + subq_6.listing + , subq_6.booking_value FROM ( -- Aggregate Measures SELECT - subq_16.listing - , SUM(subq_16.booking_value) AS booking_value + subq_5.listing + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'listing'] SELECT - subq_15.listing - , subq_15.booking_value + subq_4.listing + , subq_4.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_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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -387,91 +387,91 @@ 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_3 + ) subq_4 + ) subq_5 GROUP BY - subq_16.listing - ) subq_17 - ) subq_18 + subq_5.listing + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.listing - , subq_22.views + subq_11.listing + , subq_11.views FROM ( -- Aggregate Measures SELECT - subq_21.listing - , SUM(subq_21.views) AS views + subq_10.listing + , SUM(subq_10.views) AS views FROM ( -- Pass Only Elements: ['views', 'listing'] SELECT - subq_20.listing - , subq_20.views + subq_9.listing + , subq_9.views FROM ( -- Metric Time Dimension 'ds' 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.view__ds__day - , subq_19.view__ds__week - , subq_19.view__ds__month - , subq_19.view__ds__quarter - , subq_19.view__ds__year - , subq_19.view__ds__extract_year - , subq_19.view__ds__extract_quarter - , subq_19.view__ds__extract_month - , subq_19.view__ds__extract_day - , subq_19.view__ds__extract_dow - , subq_19.view__ds__extract_doy - , subq_19.view__ds_partitioned__day - , subq_19.view__ds_partitioned__week - , subq_19.view__ds_partitioned__month - , subq_19.view__ds_partitioned__quarter - , subq_19.view__ds_partitioned__year - , subq_19.view__ds_partitioned__extract_year - , subq_19.view__ds_partitioned__extract_quarter - , subq_19.view__ds_partitioned__extract_month - , subq_19.view__ds_partitioned__extract_day - , subq_19.view__ds_partitioned__extract_dow - , subq_19.view__ds_partitioned__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.user - , subq_19.view__listing - , subq_19.view__user - , subq_19.views + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.view__ds__day + , subq_8.view__ds__week + , subq_8.view__ds__month + , subq_8.view__ds__quarter + , subq_8.view__ds__year + , subq_8.view__ds__extract_year + , subq_8.view__ds__extract_quarter + , subq_8.view__ds__extract_month + , subq_8.view__ds__extract_day + , subq_8.view__ds__extract_dow + , subq_8.view__ds__extract_doy + , subq_8.view__ds_partitioned__day + , subq_8.view__ds_partitioned__week + , subq_8.view__ds_partitioned__month + , subq_8.view__ds_partitioned__quarter + , subq_8.view__ds_partitioned__year + , subq_8.view__ds_partitioned__extract_year + , subq_8.view__ds_partitioned__extract_quarter + , subq_8.view__ds_partitioned__extract_month + , subq_8.view__ds_partitioned__extract_day + , subq_8.view__ds_partitioned__extract_dow + , subq_8.view__ds_partitioned__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.user + , subq_8.view__listing + , subq_8.view__user + , subq_8.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT @@ -525,25 +525,25 @@ FROM ( , views_source_src_28000.listing_id AS view__listing , views_source_src_28000.user_id AS view__user FROM ***************************.fct_views views_source_src_28000 - ) subq_19 - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_21.listing - ) subq_22 - ) subq_23 + subq_10.listing + ) subq_11 + ) subq_12 ON - subq_18.listing = subq_23.listing + subq_7.listing = subq_12.listing GROUP BY - COALESCE(subq_18.listing, subq_23.listing) - ) subq_24 - ) subq_25 - ) subq_26 + COALESCE(subq_7.listing, subq_12.listing) + ) subq_13 + ) subq_14 + ) subq_15 ON - subq_13.listing = subq_26.listing - ) subq_27 - ) subq_28 + subq_2.listing = subq_15.listing + ) subq_16 + ) subq_17 WHERE listing__views_times_booking_value > 1 - ) subq_29 - ) subq_30 -) subq_31 + ) subq_18 + ) subq_19 +) subq_20 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql index f8024b63f1..e5f6bf61fb 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_58.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_45.listings AS listings + subq_36.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_23.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_45 + ) subq_23 LEFT OUTER JOIN ( -- Compute Metrics via Expressions -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] @@ -28,9 +28,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_50.listing, subq_55.listing) AS listing - , MAX(subq_50.booking_value) AS booking_value - , MAX(subq_55.views) AS views + COALESCE(subq_28.listing, subq_33.listing) AS listing + , MAX(subq_28.booking_value) AS booking_value + , MAX(subq_33.views) AS views FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -43,7 +43,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_50 + ) subq_28 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -58,17 +58,17 @@ FROM ( listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_53 + ) subq_31 GROUP BY listing - ) subq_55 + ) subq_33 ON - subq_50.listing = subq_55.listing + subq_28.listing = subq_33.listing GROUP BY - COALESCE(subq_50.listing, subq_55.listing) - ) subq_56 - ) subq_58 + COALESCE(subq_28.listing, subq_33.listing) + ) subq_34 + ) subq_36 ON - subq_45.listing = subq_58.listing -) subq_60 + subq_23.listing = subq_36.listing +) subq_38 WHERE listing__views_times_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_multiple_metrics_in_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_multiple_metrics_in_filter__plan0.sql index 1a0c7fc391..076b390821 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_multiple_metrics_in_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_multiple_metrics_in_filter__plan0.sql @@ -1,108 +1,108 @@ -- Compute Metrics via Expressions SELECT - subq_27.listings + subq_19.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_26.listings) AS listings + SUM(subq_18.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_25.listings + subq_17.listings FROM ( -- Constrain Output with WHERE SELECT - subq_24.listing__bookings - , subq_24.listing__bookers - , subq_24.listings + subq_16.listing__bookings + , subq_16.listing__bookers + , subq_16.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_23.listing__bookings - , subq_23.listing__bookers - , subq_23.listings + subq_15.listing__bookings + , subq_15.listing__bookers + , subq_15.listings FROM ( -- Join Standard Outputs SELECT - subq_10.listing AS listing - , subq_16.listing__bookings AS listing__bookings - , subq_22.listing__bookers AS listing__bookers - , subq_10.listings AS listings + subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_14.listing__bookers AS listing__bookers + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing', 'listing'] SELECT - subq_9.listing - , subq_9.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' 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.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , 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.listings - , subq_8.largest_listing - , subq_8.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -163,130 +163,130 @@ 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_8 - ) subq_9 - ) subq_10 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_15.listing - , subq_15.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_13.listing - , SUM(subq_13.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_12.listing - , subq_12.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.paid_at__day - , subq_11.paid_at__week - , subq_11.paid_at__month - , subq_11.paid_at__quarter - , subq_11.paid_at__year - , subq_11.paid_at__extract_year - , subq_11.paid_at__extract_quarter - , subq_11.paid_at__extract_month - , subq_11.paid_at__extract_day - , subq_11.paid_at__extract_dow - , subq_11.paid_at__extract_doy - , subq_11.booking__ds__day - , subq_11.booking__ds__week - , subq_11.booking__ds__month - , subq_11.booking__ds__quarter - , subq_11.booking__ds__year - , subq_11.booking__ds__extract_year - , subq_11.booking__ds__extract_quarter - , subq_11.booking__ds__extract_month - , subq_11.booking__ds__extract_day - , subq_11.booking__ds__extract_dow - , subq_11.booking__ds__extract_doy - , subq_11.booking__ds_partitioned__day - , subq_11.booking__ds_partitioned__week - , subq_11.booking__ds_partitioned__month - , subq_11.booking__ds_partitioned__quarter - , subq_11.booking__ds_partitioned__year - , subq_11.booking__ds_partitioned__extract_year - , subq_11.booking__ds_partitioned__extract_quarter - , subq_11.booking__ds_partitioned__extract_month - , subq_11.booking__ds_partitioned__extract_day - , subq_11.booking__ds_partitioned__extract_dow - , subq_11.booking__ds_partitioned__extract_doy - , subq_11.booking__paid_at__day - , subq_11.booking__paid_at__week - , subq_11.booking__paid_at__month - , subq_11.booking__paid_at__quarter - , subq_11.booking__paid_at__year - , subq_11.booking__paid_at__extract_year - , subq_11.booking__paid_at__extract_quarter - , subq_11.booking__paid_at__extract_month - , subq_11.booking__paid_at__extract_day - , subq_11.booking__paid_at__extract_dow - , subq_11.booking__paid_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.guest - , subq_11.host - , subq_11.booking__listing - , subq_11.booking__guest - , subq_11.booking__host - , subq_11.is_instant - , subq_11.booking__is_instant - , subq_11.bookings - , subq_11.instant_bookings - , subq_11.booking_value - , subq_11.max_booking_value - , subq_11.min_booking_value - , subq_11.bookers - , subq_11.average_booking_value - , subq_11.referred_bookings - , subq_11.median_booking_value - , subq_11.booking_value_p99 - , subq_11.discrete_booking_value_p99 - , subq_11.approximate_continuous_booking_value_p99 - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -379,137 +379,137 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_13.listing - ) subq_14 - ) subq_15 - ) subq_16 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_10.listing = subq_16.listing + subq_2.listing = subq_8.listing LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookers'] SELECT - subq_21.listing - , subq_21.listing__bookers + subq_13.listing + , subq_13.listing__bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_20.listing - , subq_20.bookers AS listing__bookers + subq_12.listing + , subq_12.bookers AS listing__bookers FROM ( -- Aggregate Measures SELECT - subq_19.listing - , COUNT(DISTINCT subq_19.bookers) AS bookers + subq_11.listing + , COUNT(DISTINCT subq_11.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_18.listing - , subq_18.bookers + subq_10.listing + , subq_10.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_17.ds__day - , subq_17.ds__week - , subq_17.ds__month - , subq_17.ds__quarter - , subq_17.ds__year - , subq_17.ds__extract_year - , subq_17.ds__extract_quarter - , subq_17.ds__extract_month - , subq_17.ds__extract_day - , subq_17.ds__extract_dow - , subq_17.ds__extract_doy - , subq_17.ds_partitioned__day - , subq_17.ds_partitioned__week - , subq_17.ds_partitioned__month - , subq_17.ds_partitioned__quarter - , subq_17.ds_partitioned__year - , subq_17.ds_partitioned__extract_year - , subq_17.ds_partitioned__extract_quarter - , subq_17.ds_partitioned__extract_month - , subq_17.ds_partitioned__extract_day - , subq_17.ds_partitioned__extract_dow - , subq_17.ds_partitioned__extract_doy - , subq_17.paid_at__day - , subq_17.paid_at__week - , subq_17.paid_at__month - , subq_17.paid_at__quarter - , subq_17.paid_at__year - , subq_17.paid_at__extract_year - , subq_17.paid_at__extract_quarter - , subq_17.paid_at__extract_month - , subq_17.paid_at__extract_day - , subq_17.paid_at__extract_dow - , subq_17.paid_at__extract_doy - , subq_17.booking__ds__day - , subq_17.booking__ds__week - , subq_17.booking__ds__month - , subq_17.booking__ds__quarter - , subq_17.booking__ds__year - , subq_17.booking__ds__extract_year - , subq_17.booking__ds__extract_quarter - , subq_17.booking__ds__extract_month - , subq_17.booking__ds__extract_day - , subq_17.booking__ds__extract_dow - , subq_17.booking__ds__extract_doy - , subq_17.booking__ds_partitioned__day - , subq_17.booking__ds_partitioned__week - , subq_17.booking__ds_partitioned__month - , subq_17.booking__ds_partitioned__quarter - , subq_17.booking__ds_partitioned__year - , subq_17.booking__ds_partitioned__extract_year - , subq_17.booking__ds_partitioned__extract_quarter - , subq_17.booking__ds_partitioned__extract_month - , subq_17.booking__ds_partitioned__extract_day - , subq_17.booking__ds_partitioned__extract_dow - , subq_17.booking__ds_partitioned__extract_doy - , subq_17.booking__paid_at__day - , subq_17.booking__paid_at__week - , subq_17.booking__paid_at__month - , subq_17.booking__paid_at__quarter - , subq_17.booking__paid_at__year - , subq_17.booking__paid_at__extract_year - , subq_17.booking__paid_at__extract_quarter - , subq_17.booking__paid_at__extract_month - , subq_17.booking__paid_at__extract_day - , subq_17.booking__paid_at__extract_dow - , subq_17.booking__paid_at__extract_doy - , subq_17.ds__day AS metric_time__day - , subq_17.ds__week AS metric_time__week - , subq_17.ds__month AS metric_time__month - , subq_17.ds__quarter AS metric_time__quarter - , subq_17.ds__year AS metric_time__year - , subq_17.ds__extract_year AS metric_time__extract_year - , subq_17.ds__extract_quarter AS metric_time__extract_quarter - , subq_17.ds__extract_month AS metric_time__extract_month - , subq_17.ds__extract_day AS metric_time__extract_day - , subq_17.ds__extract_dow AS metric_time__extract_dow - , subq_17.ds__extract_doy AS metric_time__extract_doy - , subq_17.listing - , subq_17.guest - , subq_17.host - , subq_17.booking__listing - , subq_17.booking__guest - , subq_17.booking__host - , subq_17.is_instant - , subq_17.booking__is_instant - , subq_17.bookings - , subq_17.instant_bookings - , subq_17.booking_value - , subq_17.max_booking_value - , subq_17.min_booking_value - , subq_17.bookers - , subq_17.average_booking_value - , subq_17.referred_bookings - , subq_17.median_booking_value - , subq_17.booking_value_p99 - , subq_17.discrete_booking_value_p99 - , subq_17.approximate_continuous_booking_value_p99 - , subq_17.approximate_discrete_booking_value_p99 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -602,19 +602,19 @@ 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_17 - ) subq_18 - ) subq_19 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_19.listing - ) subq_20 - ) subq_21 - ) subq_22 + subq_11.listing + ) subq_12 + ) subq_13 + ) subq_14 ON - subq_10.listing = subq_22.listing - ) subq_23 - ) subq_24 + subq_2.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__bookings > 2 AND listing__bookers > 1 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql index 1846b78cd5..767f0b3fea 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_44.listing__bookings AS listing__bookings - , subq_50.listing__bookers AS listing__bookers - , subq_38.listings AS listings + subq_28.listing__bookings AS listing__bookings + , subq_34.listing__bookers AS listing__bookers + , subq_22.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -19,7 +19,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_38 + ) subq_22 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,12 +35,12 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_41 + ) subq_25 GROUP BY listing - ) subq_44 + ) subq_28 ON - subq_38.listing = subq_44.listing + subq_22.listing = subq_28.listing LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -54,8 +54,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_50 + ) subq_34 ON - subq_38.listing = subq_50.listing -) subq_52 + subq_22.listing = subq_34.listing +) subq_36 WHERE listing__bookings > 2 AND listing__bookers > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_ratio_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_ratio_metric_in_where_filter__plan0.sql index a50ac4eaf1..de9c83785e 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_ratio_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_ratio_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_31.listings + subq_20.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_30.listings) AS listings + SUM(subq_19.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_29.listings + subq_18.listings FROM ( -- Constrain Output with WHERE SELECT - subq_28.listing__bookings_per_booker - , subq_28.listings + subq_17.listing__bookings_per_booker + , subq_17.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - subq_27.listing__bookings_per_booker - , subq_27.listings + subq_16.listing__bookings_per_booker + , subq_16.listings FROM ( -- Join Standard Outputs SELECT - subq_13.listing AS listing - , subq_26.listing__bookings_per_booker AS listing__bookings_per_booker - , subq_13.listings AS listings + subq_2.listing AS listing + , subq_15.listing__bookings_per_booker AS listing__bookings_per_booker + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_12.listing - , subq_12.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,141 +160,141 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] SELECT - subq_25.listing - , subq_25.listing__bookings_per_booker + subq_14.listing + , subq_14.listing__bookings_per_booker FROM ( -- Compute Metrics via Expressions SELECT - subq_24.listing - , CAST(subq_24.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_24.bookers, 0) AS DOUBLE PRECISION) AS listing__bookings_per_booker + subq_13.listing + , CAST(subq_13.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_13.bookers, 0) AS DOUBLE PRECISION) AS listing__bookings_per_booker FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.listing, subq_23.listing) AS listing - , MAX(subq_18.bookings) AS bookings - , MAX(subq_23.bookers) AS bookers + COALESCE(subq_7.listing, subq_12.listing) AS listing + , MAX(subq_7.bookings) AS bookings + , MAX(subq_12.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_17.listing - , subq_17.bookings + subq_6.listing + , subq_6.bookings FROM ( -- Aggregate Measures SELECT - subq_16.listing - , SUM(subq_16.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_15.listing - , subq_15.bookings + subq_4.listing + , subq_4.bookings 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_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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -387,129 +387,129 @@ 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_3 + ) subq_4 + ) subq_5 GROUP BY - subq_16.listing - ) subq_17 - ) subq_18 + subq_5.listing + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.listing - , subq_22.bookers + subq_11.listing + , subq_11.bookers FROM ( -- Aggregate Measures SELECT - subq_21.listing - , COUNT(DISTINCT subq_21.bookers) AS bookers + subq_10.listing + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_20.listing - , subq_20.bookers + subq_9.listing + , subq_9.bookers FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -602,25 +602,25 @@ 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_19 - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_21.listing - ) subq_22 - ) subq_23 + subq_10.listing + ) subq_11 + ) subq_12 ON - subq_18.listing = subq_23.listing + subq_7.listing = subq_12.listing GROUP BY - COALESCE(subq_18.listing, subq_23.listing) - ) subq_24 - ) subq_25 - ) subq_26 + COALESCE(subq_7.listing, subq_12.listing) + ) subq_13 + ) subq_14 + ) subq_15 ON - subq_13.listing = subq_26.listing - ) subq_27 - ) subq_28 + subq_2.listing = subq_15.listing + ) subq_16 + ) subq_17 WHERE listing__bookings_per_booker > 1 - ) subq_29 - ) subq_30 -) subq_31 + ) subq_18 + ) subq_19 +) subq_20 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql index 4047775652..8533e9e31e 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - CAST(subq_56.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_56.bookers, 0) AS DOUBLE PRECISION) AS listing__bookings_per_booker - , subq_45.listings AS listings + CAST(subq_34.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_34.bookers, 0) AS DOUBLE PRECISION) AS listing__bookings_per_booker + , subq_23.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,13 +18,13 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_45 + ) subq_23 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_50.listing, subq_55.listing) AS listing - , MAX(subq_50.bookings) AS bookings - , MAX(subq_55.bookers) AS bookers + COALESCE(subq_28.listing, subq_33.listing) AS listing + , MAX(subq_28.bookings) AS bookings + , MAX(subq_33.bookers) AS bookers FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,10 +39,10 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_48 + ) subq_26 GROUP BY listing - ) subq_50 + ) subq_28 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -55,13 +55,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_55 + ) subq_33 ON - subq_50.listing = subq_55.listing + subq_28.listing = subq_33.listing GROUP BY - COALESCE(subq_50.listing, subq_55.listing) - ) subq_56 + COALESCE(subq_28.listing, subq_33.listing) + ) subq_34 ON - subq_45.listing = subq_56.listing -) subq_60 + subq_23.listing = subq_34.listing +) subq_38 WHERE listing__bookings_per_booker > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_simple_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_simple_metric_in_where_filter__plan0.sql index f76ec704c8..d42f3e3875 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_simple_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_simple_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_17.listings + subq_13.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_16.listings) AS listings + SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_15.listings + subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.listing__bookings - , subq_14.listings + subq_10.listing__bookings + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_13.listing__bookings - , subq_13.listings + subq_9.listing__bookings + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.listing AS listing - , subq_12.listing__bookings AS listing__bookings - , subq_6.listings AS listings + subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_5.listing - , subq_5.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,130 +160,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_11.listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing - , SUM(subq_9.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_8.listing - , subq_8.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -376,19 +376,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.listing - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookings > 2 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql index 98bdb265dd..48fed36d03 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_30.listing__bookings AS listing__bookings - , subq_24.listings AS listings + subq_22.listing__bookings AS listing__bookings + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -34,11 +34,11 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_27 + ) subq_19 GROUP BY listing - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookings > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_distinct_values_query_with_metric_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_distinct_values_query_with_metric_filter__plan0.sql index ee9754ef3c..21bba933b5 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_distinct_values_query_with_metric_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_distinct_values_query_with_metric_filter__plan0.sql @@ -1,20 +1,20 @@ -- Pass Only Elements: ['listing',] SELECT - subq_12.listing + subq_8.listing FROM ( -- Constrain Output with WHERE SELECT - subq_11.listing - , subq_11.lux_listing - , subq_11.listing__lux_listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.lux_listing + , subq_7.listing__lux_listing + , subq_7.listing__bookings FROM ( -- Join Standard Outputs SELECT - subq_4.listing AS listing - , subq_4.lux_listing AS lux_listing - , subq_4.listing__lux_listing AS listing__lux_listing - , subq_10.listing__bookings AS listing__bookings + subq_0.listing AS listing + , subq_0.lux_listing AS lux_listing + , subq_0.listing__lux_listing AS listing__lux_listing + , subq_6.listing__bookings AS listing__bookings FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -22,128 +22,128 @@ FROM ( , lux_listing_mapping_src_28000.lux_listing_id AS lux_listing , lux_listing_mapping_src_28000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_28000 - ) subq_4 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_9.listing - , subq_9.listing__bookings + subq_5.listing + , subq_5.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.listing - , subq_8.bookings AS listing__bookings + subq_4.listing + , subq_4.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_7.listing - , SUM(subq_7.bookings) AS bookings + subq_3.listing + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_6.listing - , subq_6.bookings + subq_2.listing + , subq_2.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__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 + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -236,18 +236,18 @@ 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_5 - ) subq_6 - ) subq_7 + ) subq_1 + ) subq_2 + ) subq_3 GROUP BY - subq_7.listing - ) subq_8 - ) subq_9 - ) subq_10 + subq_3.listing + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_4.listing = subq_10.listing - ) subq_11 + subq_0.listing = subq_6.listing + ) subq_7 WHERE listing__bookings > 2 -) subq_12 +) subq_8 GROUP BY - subq_12.listing + subq_8.listing diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_distinct_values_query_with_metric_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_distinct_values_query_with_metric_filter__plan0_optimized.sql index cde9c960c5..d79ef0aa09 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_distinct_values_query_with_metric_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_distinct_values_query_with_metric_filter__plan0_optimized.sql @@ -6,7 +6,7 @@ FROM ( -- Join Standard Outputs SELECT lux_listing_mapping_src_28000.listing_id AS listing - , subq_23.listing__bookings AS listing__bookings + , subq_15.listing__bookings AS listing__bookings FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_28000 FULL OUTER JOIN ( -- Aggregate Measures @@ -23,13 +23,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_20 + ) subq_12 GROUP BY listing - ) subq_23 + ) subq_15 ON - lux_listing_mapping_src_28000.listing_id = subq_23.listing -) subq_24 + lux_listing_mapping_src_28000.listing_id = subq_15.listing +) subq_16 WHERE listing__bookings > 2 GROUP BY listing diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql index 3f45ae855c..f2b0169f9d 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql @@ -1,136 +1,136 @@ -- Compute Metrics via Expressions SELECT - subq_17.bookers + subq_13.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_16.bookers) AS bookers + COUNT(DISTINCT subq_12.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_15.bookers + subq_11.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_14.guest__booking_value - , subq_14.bookers + subq_10.guest__booking_value + , subq_10.bookers FROM ( -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_13.guest__booking_value - , subq_13.bookers + subq_9.guest__booking_value + , subq_9.bookers FROM ( -- Join Standard Outputs SELECT - subq_6.guest AS guest - , subq_12.guest__booking_value AS guest__booking_value - , subq_6.bookers AS bookers + subq_2.guest AS guest + , subq_8.guest__booking_value AS guest__booking_value + , subq_2.bookers AS bookers FROM ( -- Pass Only Elements: ['bookers', 'guest'] SELECT - subq_5.guest - , subq_5.bookers + subq_1.guest + , subq_1.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -223,130 +223,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['guest', 'guest__booking_value'] SELECT - subq_11.guest - , subq_11.guest__booking_value + subq_7.guest + , subq_7.guest__booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.guest - , subq_10.booking_value AS guest__booking_value + subq_6.guest + , subq_6.booking_value AS guest__booking_value FROM ( -- Aggregate Measures SELECT - subq_9.guest - , SUM(subq_9.booking_value) AS booking_value + subq_5.guest + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'guest'] SELECT - subq_8.guest - , subq_8.booking_value + subq_4.guest + , subq_4.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -439,19 +439,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.guest - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.guest + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.guest = subq_12.guest - ) subq_13 - ) subq_14 + subq_2.guest = subq_8.guest + ) subq_9 + ) subq_10 WHERE guest__booking_value > 1.00 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql index 7df3ce4738..93d184feee 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_30.guest__booking_value AS guest__booking_value - , subq_24.bookers AS bookers + subq_22.guest__booking_value AS guest__booking_value + , subq_16.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( guest_id AS guest , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY guest_id - ) subq_30 + ) subq_22 ON - subq_24.guest = subq_30.guest -) subq_32 + subq_16.guest = subq_22.guest +) subq_24 WHERE guest__booking_value > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_with_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_with_conversion_metric__plan0.sql index a45ddb8c2c..531e75e987 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_with_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_with_conversion_metric__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_39.listings + subq_24.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_38.listings) AS listings + SUM(subq_23.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_37.listings + subq_22.listings FROM ( -- Constrain Output with WHERE SELECT - subq_36.user__visit_buy_conversion_rate - , subq_36.listings + subq_21.user__visit_buy_conversion_rate + , subq_21.listings FROM ( -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - subq_35.user__visit_buy_conversion_rate - , subq_35.listings + subq_20.user__visit_buy_conversion_rate + , subq_20.listings FROM ( -- Join Standard Outputs SELECT - subq_17.user AS user - , subq_34.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate - , subq_17.listings AS listings + subq_2.user AS user + , subq_19.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_16.user - , subq_16.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,79 +160,79 @@ 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_15 - ) subq_16 - ) subq_17 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] SELECT - subq_33.user - , subq_33.user__visit_buy_conversion_rate + subq_18.user + , subq_18.user__visit_buy_conversion_rate FROM ( -- Compute Metrics via Expressions SELECT - subq_32.user - , CAST(subq_32.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_32.visits, 0) AS DOUBLE PRECISION) AS user__visit_buy_conversion_rate + subq_17.user + , CAST(subq_17.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE PRECISION) AS user__visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.user, subq_31.user) AS user - , MAX(subq_21.visits) AS visits - , MAX(subq_31.buys) AS buys + COALESCE(subq_6.user, subq_16.user) AS user + , MAX(subq_6.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_20.user - , SUM(subq_20.visits) AS visits + subq_5.user + , SUM(subq_5.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'user'] SELECT - subq_19.user - , subq_19.visits + subq_4.user + , subq_4.visits 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.visit__ds__day - , subq_18.visit__ds__week - , subq_18.visit__ds__month - , subq_18.visit__ds__quarter - , subq_18.visit__ds__year - , subq_18.visit__ds__extract_year - , subq_18.visit__ds__extract_quarter - , subq_18.visit__ds__extract_month - , subq_18.visit__ds__extract_day - , subq_18.visit__ds__extract_dow - , subq_18.visit__ds__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.user - , subq_18.session - , subq_18.visit__user - , subq_18.visit__session - , subq_18.referrer_id - , subq_18.visit__referrer_id - , subq_18.visits - , subq_18.visitors + 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.visit__ds__day + , subq_3.visit__ds__week + , subq_3.visit__ds__month + , subq_3.visit__ds__quarter + , subq_3.visit__ds__year + , subq_3.visit__ds__extract_year + , subq_3.visit__ds__extract_quarter + , subq_3.visit__ds__extract_month + , subq_3.visit__ds__extract_day + , subq_3.visit__ds__extract_dow + , subq_3.visit__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_3.user + , subq_3.session + , subq_3.visit__user + , subq_3.visit__session + , subq_3.referrer_id + , subq_3.visit__referrer_id + , subq_3.visits + , subq_3.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -267,108 +267,108 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_18 - ) subq_19 - ) subq_20 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_20.user - ) subq_21 + subq_5.user + ) subq_6 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_30.user - , SUM(subq_30.buys) AS buys + subq_15.user + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'user'] SELECT - subq_29.user - , subq_29.buys + subq_14.user + , subq_14.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_28.ds__day - , subq_28.user - , subq_28.buys - , subq_28.visits + subq_13.ds__day + , subq_13.user + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_24.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_24.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_24.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_27.mf_internal_uuid AS mf_internal_uuid - , subq_27.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_23.ds__day - , subq_23.user - , subq_23.visits + subq_8.ds__day + , subq_8.user + , subq_8.visits 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.visit__ds__day - , subq_22.visit__ds__week - , subq_22.visit__ds__month - , subq_22.visit__ds__quarter - , subq_22.visit__ds__year - , subq_22.visit__ds__extract_year - , subq_22.visit__ds__extract_quarter - , subq_22.visit__ds__extract_month - , subq_22.visit__ds__extract_day - , subq_22.visit__ds__extract_dow - , subq_22.visit__ds__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.user - , subq_22.session - , subq_22.visit__user - , subq_22.visit__session - , subq_22.referrer_id - , subq_22.visit__referrer_id - , subq_22.visits - , subq_22.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -403,94 +403,94 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_22 - ) subq_23 - ) subq_24 + ) subq_7 + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_26.ds__day - , subq_26.ds__week - , subq_26.ds__month - , subq_26.ds__quarter - , subq_26.ds__year - , subq_26.ds__extract_year - , subq_26.ds__extract_quarter - , subq_26.ds__extract_month - , subq_26.ds__extract_day - , subq_26.ds__extract_dow - , subq_26.ds__extract_doy - , subq_26.buy__ds__day - , subq_26.buy__ds__week - , subq_26.buy__ds__month - , subq_26.buy__ds__quarter - , subq_26.buy__ds__year - , subq_26.buy__ds__extract_year - , subq_26.buy__ds__extract_quarter - , subq_26.buy__ds__extract_month - , subq_26.buy__ds__extract_day - , subq_26.buy__ds__extract_dow - , subq_26.buy__ds__extract_doy - , subq_26.metric_time__day - , subq_26.metric_time__week - , subq_26.metric_time__month - , subq_26.metric_time__quarter - , subq_26.metric_time__year - , subq_26.metric_time__extract_year - , subq_26.metric_time__extract_quarter - , subq_26.metric_time__extract_month - , subq_26.metric_time__extract_day - , subq_26.metric_time__extract_dow - , subq_26.metric_time__extract_doy - , subq_26.user - , subq_26.session_id - , subq_26.buy__user - , subq_26.buy__session_id - , subq_26.buys - , subq_26.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_25.ds__day - , subq_25.ds__week - , subq_25.ds__month - , subq_25.ds__quarter - , subq_25.ds__year - , subq_25.ds__extract_year - , subq_25.ds__extract_quarter - , subq_25.ds__extract_month - , subq_25.ds__extract_day - , subq_25.ds__extract_dow - , subq_25.ds__extract_doy - , subq_25.buy__ds__day - , subq_25.buy__ds__week - , subq_25.buy__ds__month - , subq_25.buy__ds__quarter - , subq_25.buy__ds__year - , subq_25.buy__ds__extract_year - , subq_25.buy__ds__extract_quarter - , subq_25.buy__ds__extract_month - , subq_25.buy__ds__extract_day - , subq_25.buy__ds__extract_dow - , subq_25.buy__ds__extract_doy - , subq_25.ds__day AS metric_time__day - , subq_25.ds__week AS metric_time__week - , subq_25.ds__month AS metric_time__month - , subq_25.ds__quarter AS metric_time__quarter - , subq_25.ds__year AS metric_time__year - , subq_25.ds__extract_year AS metric_time__extract_year - , subq_25.ds__extract_quarter AS metric_time__extract_quarter - , subq_25.ds__extract_month AS metric_time__extract_month - , subq_25.ds__extract_day AS metric_time__extract_day - , subq_25.ds__extract_dow AS metric_time__extract_dow - , subq_25.ds__extract_doy AS metric_time__extract_doy - , subq_25.user - , subq_25.session_id - , subq_25.buy__user - , subq_25.buy__session_id - , subq_25.buys - , subq_25.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -523,33 +523,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_25 - ) subq_26 - ) subq_27 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_24.user = subq_27.user + subq_9.user = subq_12.user ) AND ( - (subq_24.ds__day <= subq_27.ds__day) + (subq_9.ds__day <= subq_12.ds__day) ) - ) subq_28 - ) subq_29 - ) subq_30 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY - subq_30.user - ) subq_31 + subq_15.user + ) subq_16 ON - subq_21.user = subq_31.user + subq_6.user = subq_16.user GROUP BY - COALESCE(subq_21.user, subq_31.user) - ) subq_32 - ) subq_33 - ) subq_34 + COALESCE(subq_6.user, subq_16.user) + ) subq_17 + ) subq_18 + ) subq_19 ON - subq_17.user = subq_34.user - ) subq_35 - ) subq_36 + subq_2.user = subq_19.user + ) subq_20 + ) subq_21 WHERE user__visit_buy_conversion_rate > 2 - ) subq_37 - ) subq_38 -) subq_39 + ) subq_22 + ) subq_23 +) subq_24 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_with_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_with_conversion_metric__plan0_optimized.sql index 4853fd081b..202c5e89d0 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_with_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_with_conversion_metric__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - CAST(subq_72.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_72.visits, 0) AS DOUBLE PRECISION) AS user__visit_buy_conversion_rate - , subq_57.listings AS listings + CAST(subq_42.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_42.visits, 0) AS DOUBLE PRECISION) AS user__visit_buy_conversion_rate + , subq_27.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,17 +18,17 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_57 + ) subq_27 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_61.user, subq_71.user) AS user - , MAX(subq_61.visits) AS visits - , MAX(subq_71.buys) AS buys + COALESCE(subq_31.user, subq_41.user) AS user + , MAX(subq_31.visits) AS visits + , MAX(subq_41.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_60.user + subq_30.user , SUM(visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -38,46 +38,46 @@ FROM ( user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_60 + ) subq_30 GROUP BY - subq_60.user - ) subq_61 + subq_30.user + ) subq_31 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'user'] -- Aggregate Measures SELECT - subq_68.user + subq_38.user , SUM(buys) AS buys FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_64.visits) OVER ( + first_value(subq_34.visits) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_64.ds__day) OVER ( + , first_value(subq_34.ds__day) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_64.user) OVER ( + , first_value(subq_34.user) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_67.mf_internal_uuid AS mf_internal_uuid - , subq_67.buys AS buys + , subq_37.mf_internal_uuid AS mf_internal_uuid + , subq_37.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -87,7 +87,7 @@ FROM ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_64 + ) subq_34 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -98,23 +98,23 @@ FROM ( , 1 AS buys , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_67 + ) subq_37 ON ( - subq_64.user = subq_67.user + subq_34.user = subq_37.user ) AND ( - (subq_64.ds__day <= subq_67.ds__day) + (subq_34.ds__day <= subq_37.ds__day) ) - ) subq_68 + ) subq_38 GROUP BY - subq_68.user - ) subq_71 + subq_38.user + ) subq_41 ON - subq_61.user = subq_71.user + subq_31.user = subq_41.user GROUP BY - COALESCE(subq_61.user, subq_71.user) - ) subq_72 + COALESCE(subq_31.user, subq_41.user) + ) subq_42 ON - subq_57.user = subq_72.user -) subq_76 + subq_27.user = subq_42.user +) subq_46 WHERE user__visit_buy_conversion_rate > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_group_by_has_local_entity_prefix__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_group_by_has_local_entity_prefix__plan0.sql index b87e05ef02..4077c6d0b8 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_group_by_has_local_entity_prefix__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_group_by_has_local_entity_prefix__plan0.sql @@ -1,106 +1,106 @@ -- Compute Metrics via Expressions SELECT - subq_27.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_26.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_25.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_24.user__listing__user__average_booking_value - , subq_24.listings + subq_15.user__listing__user__average_booking_value + , subq_15.listings FROM ( -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_23.user__listing__user__average_booking_value - , subq_23.listings + subq_14.user__listing__user__average_booking_value + , subq_14.listings FROM ( -- Join Standard Outputs SELECT - subq_11.user AS user - , subq_22.listing__user AS user__listing__user - , subq_22.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_11.listings AS listings + subq_2.user AS user + , subq_13.listing__user AS user__listing__user + , subq_13.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_10.user - , subq_10.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__extract_quarter - , subq_9.ds__extract_month - , subq_9.ds__extract_day - , subq_9.ds__extract_dow - , subq_9.ds__extract_doy - , subq_9.created_at__day - , subq_9.created_at__week - , subq_9.created_at__month - , subq_9.created_at__quarter - , subq_9.created_at__year - , subq_9.created_at__extract_year - , subq_9.created_at__extract_quarter - , subq_9.created_at__extract_month - , subq_9.created_at__extract_day - , subq_9.created_at__extract_dow - , subq_9.created_at__extract_doy - , subq_9.listing__ds__day - , subq_9.listing__ds__week - , subq_9.listing__ds__month - , subq_9.listing__ds__quarter - , subq_9.listing__ds__year - , subq_9.listing__ds__extract_year - , subq_9.listing__ds__extract_quarter - , subq_9.listing__ds__extract_month - , subq_9.listing__ds__extract_day - , subq_9.listing__ds__extract_dow - , subq_9.listing__ds__extract_doy - , subq_9.listing__created_at__day - , subq_9.listing__created_at__week - , subq_9.listing__created_at__month - , subq_9.listing__created_at__quarter - , subq_9.listing__created_at__year - , subq_9.listing__created_at__extract_year - , subq_9.listing__created_at__extract_quarter - , subq_9.listing__created_at__extract_month - , subq_9.listing__created_at__extract_day - , subq_9.listing__created_at__extract_dow - , subq_9.listing__created_at__extract_doy - , subq_9.ds__day AS metric_time__day - , subq_9.ds__week AS metric_time__week - , subq_9.ds__month AS metric_time__month - , subq_9.ds__quarter AS metric_time__quarter - , subq_9.ds__year AS metric_time__year - , subq_9.ds__extract_year AS metric_time__extract_year - , subq_9.ds__extract_quarter AS metric_time__extract_quarter - , subq_9.ds__extract_month AS metric_time__extract_month - , subq_9.ds__extract_day AS metric_time__extract_day - , subq_9.ds__extract_dow AS metric_time__extract_dow - , subq_9.ds__extract_doy AS metric_time__extract_doy - , subq_9.listing - , subq_9.user - , subq_9.listing__user - , subq_9.country_latest - , subq_9.is_lux_latest - , subq_9.capacity_latest - , subq_9.listing__country_latest - , subq_9.listing__is_lux_latest - , subq_9.listing__capacity_latest - , subq_9.listings - , subq_9.largest_listing - , subq_9.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -161,141 +161,141 @@ 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_9 - ) subq_10 - ) subq_11 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] SELECT - subq_21.listing__user - , subq_21.listing__user__average_booking_value + subq_12.listing__user + , subq_12.listing__user__average_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_20.listing__user - , subq_20.average_booking_value AS listing__user__average_booking_value + subq_11.listing__user + , subq_11.average_booking_value AS listing__user__average_booking_value FROM ( -- Aggregate Measures SELECT - subq_19.listing__user - , AVG(subq_19.average_booking_value) AS average_booking_value + subq_10.listing__user + , AVG(subq_10.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__user'] SELECT - subq_18.listing__user - , subq_18.average_booking_value + subq_9.listing__user + , subq_9.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_14.listing AS listing - , subq_17.user AS listing__user - , subq_14.average_booking_value AS average_booking_value + subq_5.listing AS listing + , subq_8.user AS listing__user + , subq_5.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing'] SELECT - subq_13.listing - , subq_13.average_booking_value + subq_4.listing + , subq_4.average_booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -388,84 +388,84 @@ 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_12 - ) subq_13 - ) subq_14 + ) subq_3 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'user'] SELECT - subq_16.listing - , subq_16.user + subq_7.listing + , subq_7.user FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.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 @@ -526,23 +526,23 @@ 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_15 - ) subq_16 - ) subq_17 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_5.listing = subq_8.listing + ) subq_9 + ) subq_10 GROUP BY - subq_19.listing__user - ) subq_20 - ) subq_21 - ) subq_22 + subq_10.listing__user + ) subq_11 + ) subq_12 + ) subq_13 ON - subq_11.user = subq_22.listing__user - ) subq_23 - ) subq_24 + subq_2.user = subq_13.listing__user + ) subq_14 + ) subq_15 WHERE user__listing__user__average_booking_value > 1 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_group_by_has_local_entity_prefix__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_group_by_has_local_entity_prefix__plan0_optimized.sql index f2d9e26580..8a2de81699 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_group_by_has_local_entity_prefix__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_group_by_has_local_entity_prefix__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_50.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_39.listings AS listings + subq_32.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_21.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_39 + ) subq_21 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__user'] @@ -35,8 +35,8 @@ FROM ( bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY listings_latest_src_28000.user_id - ) subq_50 + ) subq_32 ON - subq_39.user = subq_50.listing__user -) subq_52 + subq_21.user = subq_32.listing__user +) subq_34 WHERE user__listing__user__average_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_multi_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_multi_hop__plan0.sql index 2bb04ef38c..4e4fa8d309 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_multi_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_multi_hop__plan0.sql @@ -1,76 +1,76 @@ -- Compute Metrics via Expressions SELECT - subq_40.third_hop_count + subq_22.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_39.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_21.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_38.third_hop_count + subq_20.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_37.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_37.third_hop_count + subq_19.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_19.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_36.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_36.third_hop_count + subq_18.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_18.third_hop_count FROM ( -- Join Standard Outputs SELECT - subq_20.customer_third_hop_id AS customer_third_hop_id - , subq_35.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id - , subq_35.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_20.third_hop_count AS third_hop_count + subq_2.customer_third_hop_id AS customer_third_hop_id + , subq_17.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_17.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_2.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_19.customer_third_hop_id - , subq_19.third_hop_count + subq_1.customer_third_hop_id + , subq_1.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - subq_18.third_hop_ds__day - , subq_18.third_hop_ds__week - , subq_18.third_hop_ds__month - , subq_18.third_hop_ds__quarter - , subq_18.third_hop_ds__year - , subq_18.third_hop_ds__extract_year - , subq_18.third_hop_ds__extract_quarter - , subq_18.third_hop_ds__extract_month - , subq_18.third_hop_ds__extract_day - , subq_18.third_hop_ds__extract_dow - , subq_18.third_hop_ds__extract_doy - , subq_18.customer_third_hop_id__third_hop_ds__day - , subq_18.customer_third_hop_id__third_hop_ds__week - , subq_18.customer_third_hop_id__third_hop_ds__month - , subq_18.customer_third_hop_id__third_hop_ds__quarter - , subq_18.customer_third_hop_id__third_hop_ds__year - , subq_18.customer_third_hop_id__third_hop_ds__extract_year - , subq_18.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_18.customer_third_hop_id__third_hop_ds__extract_month - , subq_18.customer_third_hop_id__third_hop_ds__extract_day - , subq_18.customer_third_hop_id__third_hop_ds__extract_dow - , subq_18.customer_third_hop_id__third_hop_ds__extract_doy - , subq_18.third_hop_ds__day AS metric_time__day - , subq_18.third_hop_ds__week AS metric_time__week - , subq_18.third_hop_ds__month AS metric_time__month - , subq_18.third_hop_ds__quarter AS metric_time__quarter - , subq_18.third_hop_ds__year AS metric_time__year - , subq_18.third_hop_ds__extract_year AS metric_time__extract_year - , subq_18.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_18.third_hop_ds__extract_month AS metric_time__extract_month - , subq_18.third_hop_ds__extract_day AS metric_time__extract_day - , subq_18.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_18.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_18.customer_third_hop_id - , subq_18.value - , subq_18.customer_third_hop_id__value - , subq_18.third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( -- Read Elements From Semantic Model 'third_hop_table' SELECT @@ -101,105 +101,105 @@ 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_18 - ) subq_19 - ) subq_20 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_34.account_id__customer_id__customer_third_hop_id - , subq_34.account_id__customer_id__customer_third_hop_id__txn_count + subq_16.account_id__customer_id__customer_third_hop_id + , subq_16.account_id__customer_id__customer_third_hop_id__txn_count FROM ( -- Compute Metrics via Expressions SELECT - subq_33.account_id__customer_id__customer_third_hop_id - , subq_33.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count + subq_15.account_id__customer_id__customer_third_hop_id + , subq_15.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count FROM ( -- Aggregate Measures SELECT - subq_32.account_id__customer_id__customer_third_hop_id - , SUM(subq_32.txn_count) AS txn_count + subq_14.account_id__customer_id__customer_third_hop_id + , SUM(subq_14.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] SELECT - subq_31.account_id__customer_id__customer_third_hop_id - , subq_31.txn_count + subq_13.account_id__customer_id__customer_third_hop_id + , subq_13.txn_count FROM ( -- Join Standard Outputs SELECT - subq_23.ds_partitioned__day AS ds_partitioned__day - , subq_30.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_23.account_id AS account_id - , subq_30.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id - , subq_23.txn_count AS txn_count + subq_5.ds_partitioned__day AS ds_partitioned__day + , subq_12.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_5.account_id AS account_id + , subq_12.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + , subq_5.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_22.ds_partitioned__day - , subq_22.account_id - , subq_22.txn_count + subq_4.ds_partitioned__day + , subq_4.account_id + , subq_4.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_21.ds_partitioned__day - , subq_21.ds_partitioned__week - , subq_21.ds_partitioned__month - , subq_21.ds_partitioned__quarter - , subq_21.ds_partitioned__year - , subq_21.ds_partitioned__extract_year - , subq_21.ds_partitioned__extract_quarter - , subq_21.ds_partitioned__extract_month - , subq_21.ds_partitioned__extract_day - , subq_21.ds_partitioned__extract_dow - , subq_21.ds_partitioned__extract_doy - , subq_21.ds__day - , subq_21.ds__week - , subq_21.ds__month - , subq_21.ds__quarter - , subq_21.ds__year - , subq_21.ds__extract_year - , subq_21.ds__extract_quarter - , subq_21.ds__extract_month - , subq_21.ds__extract_day - , subq_21.ds__extract_dow - , subq_21.ds__extract_doy - , subq_21.account_id__ds_partitioned__day - , subq_21.account_id__ds_partitioned__week - , subq_21.account_id__ds_partitioned__month - , subq_21.account_id__ds_partitioned__quarter - , subq_21.account_id__ds_partitioned__year - , subq_21.account_id__ds_partitioned__extract_year - , subq_21.account_id__ds_partitioned__extract_quarter - , subq_21.account_id__ds_partitioned__extract_month - , subq_21.account_id__ds_partitioned__extract_day - , subq_21.account_id__ds_partitioned__extract_dow - , subq_21.account_id__ds_partitioned__extract_doy - , subq_21.account_id__ds__day - , subq_21.account_id__ds__week - , subq_21.account_id__ds__month - , subq_21.account_id__ds__quarter - , subq_21.account_id__ds__year - , subq_21.account_id__ds__extract_year - , subq_21.account_id__ds__extract_quarter - , subq_21.account_id__ds__extract_month - , subq_21.account_id__ds__extract_day - , subq_21.account_id__ds__extract_dow - , subq_21.account_id__ds__extract_doy - , subq_21.ds__day AS metric_time__day - , subq_21.ds__week AS metric_time__week - , subq_21.ds__month AS metric_time__month - , subq_21.ds__quarter AS metric_time__quarter - , subq_21.ds__year AS metric_time__year - , subq_21.ds__extract_year AS metric_time__extract_year - , subq_21.ds__extract_quarter AS metric_time__extract_quarter - , subq_21.ds__extract_month AS metric_time__extract_month - , subq_21.ds__extract_day AS metric_time__extract_day - , subq_21.ds__extract_dow AS metric_time__extract_dow - , subq_21.ds__extract_doy AS metric_time__extract_doy - , subq_21.account_id - , subq_21.account_month - , subq_21.account_id__account_month - , subq_21.txn_count + 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.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.account_id__ds_partitioned__day + , subq_3.account_id__ds_partitioned__week + , subq_3.account_id__ds_partitioned__month + , subq_3.account_id__ds_partitioned__quarter + , subq_3.account_id__ds_partitioned__year + , subq_3.account_id__ds_partitioned__extract_year + , subq_3.account_id__ds_partitioned__extract_quarter + , subq_3.account_id__ds_partitioned__extract_month + , subq_3.account_id__ds_partitioned__extract_day + , subq_3.account_id__ds_partitioned__extract_dow + , subq_3.account_id__ds_partitioned__extract_doy + , subq_3.account_id__ds__day + , subq_3.account_id__ds__week + , subq_3.account_id__ds__month + , subq_3.account_id__ds__quarter + , subq_3.account_id__ds__year + , subq_3.account_id__ds__extract_year + , subq_3.account_id__ds__extract_quarter + , subq_3.account_id__ds__extract_month + , subq_3.account_id__ds__extract_day + , subq_3.account_id__ds__extract_dow + , subq_3.account_id__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_3.account_id + , subq_3.account_month + , subq_3.account_id__account_month + , subq_3.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -252,164 +252,164 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_3 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] SELECT - subq_29.ds_partitioned__day - , subq_29.account_id - , subq_29.customer_id__customer_third_hop_id + subq_11.ds_partitioned__day + , subq_11.account_id + , subq_11.customer_id__customer_third_hop_id FROM ( -- Join Standard Outputs SELECT - subq_25.ds_partitioned__day AS ds_partitioned__day - , subq_25.ds_partitioned__week AS ds_partitioned__week - , subq_25.ds_partitioned__month AS ds_partitioned__month - , subq_25.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_25.ds_partitioned__year AS ds_partitioned__year - , subq_25.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_25.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_25.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_25.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_25.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_25.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_25.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_25.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_25.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_25.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_25.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_25.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_25.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_25.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_25.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_25.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_25.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_25.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_25.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_25.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_25.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_25.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_25.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_25.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_25.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_25.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_25.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_25.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_25.metric_time__day AS metric_time__day - , subq_25.metric_time__week AS metric_time__week - , subq_25.metric_time__month AS metric_time__month - , subq_25.metric_time__quarter AS metric_time__quarter - , subq_25.metric_time__year AS metric_time__year - , subq_25.metric_time__extract_year AS metric_time__extract_year - , subq_25.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_25.metric_time__extract_month AS metric_time__extract_month - , subq_25.metric_time__extract_day AS metric_time__extract_day - , subq_25.metric_time__extract_dow AS metric_time__extract_dow - , subq_25.metric_time__extract_doy AS metric_time__extract_doy - , subq_28.acquired_ds__day AS customer_id__acquired_ds__day - , subq_28.acquired_ds__week AS customer_id__acquired_ds__week - , subq_28.acquired_ds__month AS customer_id__acquired_ds__month - , subq_28.acquired_ds__quarter AS customer_id__acquired_ds__quarter - , subq_28.acquired_ds__year AS customer_id__acquired_ds__year - , subq_28.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year - , subq_28.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter - , subq_28.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month - , subq_28.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day - , subq_28.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow - , subq_28.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy - , subq_28.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day - , subq_28.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week - , subq_28.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month - , subq_28.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter - , subq_28.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year - , subq_28.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year - , subq_28.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter - , subq_28.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month - , subq_28.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day - , subq_28.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow - , subq_28.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy - , subq_28.metric_time__day AS customer_id__metric_time__day - , subq_28.metric_time__week AS customer_id__metric_time__week - , subq_28.metric_time__month AS customer_id__metric_time__month - , subq_28.metric_time__quarter AS customer_id__metric_time__quarter - , subq_28.metric_time__year AS customer_id__metric_time__year - , subq_28.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_28.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_28.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_28.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_28.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_28.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_25.account_id AS account_id - , subq_25.customer_id AS customer_id - , subq_25.account_id__customer_id AS account_id__customer_id - , subq_25.bridge_account__account_id AS bridge_account__account_id - , subq_25.bridge_account__customer_id AS bridge_account__customer_id - , subq_28.customer_third_hop_id AS customer_id__customer_third_hop_id - , subq_28.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id - , subq_25.extra_dim AS extra_dim - , subq_25.account_id__extra_dim AS account_id__extra_dim - , subq_25.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_28.country AS customer_id__country - , subq_28.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country - , subq_25.account_customer_combos AS account_customer_combos + subq_7.ds_partitioned__day AS ds_partitioned__day + , subq_7.ds_partitioned__week AS ds_partitioned__week + , subq_7.ds_partitioned__month AS ds_partitioned__month + , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_7.ds_partitioned__year AS ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_7.metric_time__day AS metric_time__day + , subq_7.metric_time__week AS metric_time__week + , subq_7.metric_time__month AS metric_time__month + , subq_7.metric_time__quarter AS metric_time__quarter + , subq_7.metric_time__year AS metric_time__year + , subq_7.metric_time__extract_year AS metric_time__extract_year + , subq_7.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_7.metric_time__extract_month AS metric_time__extract_month + , subq_7.metric_time__extract_day AS metric_time__extract_day + , subq_7.metric_time__extract_dow AS metric_time__extract_dow + , subq_7.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.acquired_ds__day AS customer_id__acquired_ds__day + , subq_10.acquired_ds__week AS customer_id__acquired_ds__week + , subq_10.acquired_ds__month AS customer_id__acquired_ds__month + , subq_10.acquired_ds__quarter AS customer_id__acquired_ds__quarter + , subq_10.acquired_ds__year AS customer_id__acquired_ds__year + , subq_10.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year + , subq_10.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter + , subq_10.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month + , subq_10.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day + , subq_10.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow + , subq_10.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy + , subq_10.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day + , subq_10.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week + , subq_10.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month + , subq_10.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter + , subq_10.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year + , subq_10.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year + , subq_10.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter + , subq_10.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month + , subq_10.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day + , subq_10.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow + , subq_10.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy + , subq_10.metric_time__day AS customer_id__metric_time__day + , subq_10.metric_time__week AS customer_id__metric_time__week + , subq_10.metric_time__month AS customer_id__metric_time__month + , subq_10.metric_time__quarter AS customer_id__metric_time__quarter + , subq_10.metric_time__year AS customer_id__metric_time__year + , subq_10.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_10.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_10.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_10.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_10.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_10.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_7.account_id AS account_id + , subq_7.customer_id AS customer_id + , subq_7.account_id__customer_id AS account_id__customer_id + , subq_7.bridge_account__account_id AS bridge_account__account_id + , subq_7.bridge_account__customer_id AS bridge_account__customer_id + , subq_10.customer_third_hop_id AS customer_id__customer_third_hop_id + , subq_10.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id + , subq_7.extra_dim AS extra_dim + , subq_7.account_id__extra_dim AS account_id__extra_dim + , subq_7.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_10.country AS customer_id__country + , subq_10.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country + , subq_7.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.account_id__ds_partitioned__day - , subq_24.account_id__ds_partitioned__week - , subq_24.account_id__ds_partitioned__month - , subq_24.account_id__ds_partitioned__quarter - , subq_24.account_id__ds_partitioned__year - , subq_24.account_id__ds_partitioned__extract_year - , subq_24.account_id__ds_partitioned__extract_quarter - , subq_24.account_id__ds_partitioned__extract_month - , subq_24.account_id__ds_partitioned__extract_day - , subq_24.account_id__ds_partitioned__extract_dow - , subq_24.account_id__ds_partitioned__extract_doy - , subq_24.bridge_account__ds_partitioned__day - , subq_24.bridge_account__ds_partitioned__week - , subq_24.bridge_account__ds_partitioned__month - , subq_24.bridge_account__ds_partitioned__quarter - , subq_24.bridge_account__ds_partitioned__year - , subq_24.bridge_account__ds_partitioned__extract_year - , subq_24.bridge_account__ds_partitioned__extract_quarter - , subq_24.bridge_account__ds_partitioned__extract_month - , subq_24.bridge_account__ds_partitioned__extract_day - , subq_24.bridge_account__ds_partitioned__extract_dow - , subq_24.bridge_account__ds_partitioned__extract_doy - , subq_24.ds_partitioned__day AS metric_time__day - , subq_24.ds_partitioned__week AS metric_time__week - , subq_24.ds_partitioned__month AS metric_time__month - , subq_24.ds_partitioned__quarter AS metric_time__quarter - , subq_24.ds_partitioned__year AS metric_time__year - , subq_24.ds_partitioned__extract_year AS metric_time__extract_year - , subq_24.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_24.ds_partitioned__extract_month AS metric_time__extract_month - , subq_24.ds_partitioned__extract_day AS metric_time__extract_day - , subq_24.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_24.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_24.account_id - , subq_24.customer_id - , subq_24.account_id__customer_id - , subq_24.bridge_account__account_id - , subq_24.bridge_account__customer_id - , subq_24.extra_dim - , subq_24.account_id__extra_dim - , subq_24.bridge_account__extra_dim - , subq_24.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_6.account_id__ds_partitioned__week + , subq_6.account_id__ds_partitioned__month + , subq_6.account_id__ds_partitioned__quarter + , subq_6.account_id__ds_partitioned__year + , subq_6.account_id__ds_partitioned__extract_year + , subq_6.account_id__ds_partitioned__extract_quarter + , subq_6.account_id__ds_partitioned__extract_month + , subq_6.account_id__ds_partitioned__extract_day + , subq_6.account_id__ds_partitioned__extract_dow + , subq_6.account_id__ds_partitioned__extract_doy + , subq_6.bridge_account__ds_partitioned__day + , subq_6.bridge_account__ds_partitioned__week + , subq_6.bridge_account__ds_partitioned__month + , subq_6.bridge_account__ds_partitioned__quarter + , subq_6.bridge_account__ds_partitioned__year + , subq_6.bridge_account__ds_partitioned__extract_year + , subq_6.bridge_account__ds_partitioned__extract_quarter + , subq_6.bridge_account__ds_partitioned__extract_month + , subq_6.bridge_account__ds_partitioned__extract_day + , subq_6.bridge_account__ds_partitioned__extract_dow + , subq_6.bridge_account__ds_partitioned__extract_doy + , subq_6.ds_partitioned__day AS metric_time__day + , subq_6.ds_partitioned__week AS metric_time__week + , subq_6.ds_partitioned__month AS metric_time__month + , subq_6.ds_partitioned__quarter AS metric_time__quarter + , subq_6.ds_partitioned__year AS metric_time__year + , subq_6.ds_partitioned__extract_year AS metric_time__extract_year + , subq_6.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_6.ds_partitioned__extract_month AS metric_time__extract_month + , subq_6.ds_partitioned__extract_day AS metric_time__extract_day + , subq_6.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_6.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_6.account_id + , subq_6.customer_id + , subq_6.account_id__customer_id + , subq_6.bridge_account__account_id + , subq_6.bridge_account__customer_id + , subq_6.extra_dim + , subq_6.account_id__extra_dim + , subq_6.bridge_account__extra_dim + , subq_6.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -456,8 +456,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_24 - ) subq_25 + ) subq_6 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'country', @@ -513,112 +513,112 @@ FROM ( -- 'customer_third_hop_id__customer_id', -- ] SELECT - subq_27.acquired_ds__day - , subq_27.acquired_ds__week - , subq_27.acquired_ds__month - , subq_27.acquired_ds__quarter - , subq_27.acquired_ds__year - , subq_27.acquired_ds__extract_year - , subq_27.acquired_ds__extract_quarter - , subq_27.acquired_ds__extract_month - , subq_27.acquired_ds__extract_day - , subq_27.acquired_ds__extract_dow - , subq_27.acquired_ds__extract_doy - , subq_27.customer_id__acquired_ds__day - , subq_27.customer_id__acquired_ds__week - , subq_27.customer_id__acquired_ds__month - , subq_27.customer_id__acquired_ds__quarter - , subq_27.customer_id__acquired_ds__year - , subq_27.customer_id__acquired_ds__extract_year - , subq_27.customer_id__acquired_ds__extract_quarter - , subq_27.customer_id__acquired_ds__extract_month - , subq_27.customer_id__acquired_ds__extract_day - , subq_27.customer_id__acquired_ds__extract_dow - , subq_27.customer_id__acquired_ds__extract_doy - , subq_27.customer_third_hop_id__acquired_ds__day - , subq_27.customer_third_hop_id__acquired_ds__week - , subq_27.customer_third_hop_id__acquired_ds__month - , subq_27.customer_third_hop_id__acquired_ds__quarter - , subq_27.customer_third_hop_id__acquired_ds__year - , subq_27.customer_third_hop_id__acquired_ds__extract_year - , subq_27.customer_third_hop_id__acquired_ds__extract_quarter - , subq_27.customer_third_hop_id__acquired_ds__extract_month - , subq_27.customer_third_hop_id__acquired_ds__extract_day - , subq_27.customer_third_hop_id__acquired_ds__extract_dow - , subq_27.customer_third_hop_id__acquired_ds__extract_doy - , subq_27.metric_time__day - , subq_27.metric_time__week - , subq_27.metric_time__month - , subq_27.metric_time__quarter - , subq_27.metric_time__year - , subq_27.metric_time__extract_year - , subq_27.metric_time__extract_quarter - , subq_27.metric_time__extract_month - , subq_27.metric_time__extract_day - , subq_27.metric_time__extract_dow - , subq_27.metric_time__extract_doy - , subq_27.customer_id - , subq_27.customer_third_hop_id - , subq_27.customer_id__customer_third_hop_id - , subq_27.customer_third_hop_id__customer_id - , subq_27.country - , subq_27.customer_id__country - , subq_27.customer_third_hop_id__country + subq_9.acquired_ds__day + , subq_9.acquired_ds__week + , subq_9.acquired_ds__month + , subq_9.acquired_ds__quarter + , subq_9.acquired_ds__year + , subq_9.acquired_ds__extract_year + , subq_9.acquired_ds__extract_quarter + , subq_9.acquired_ds__extract_month + , subq_9.acquired_ds__extract_day + , subq_9.acquired_ds__extract_dow + , subq_9.acquired_ds__extract_doy + , subq_9.customer_id__acquired_ds__day + , subq_9.customer_id__acquired_ds__week + , subq_9.customer_id__acquired_ds__month + , subq_9.customer_id__acquired_ds__quarter + , subq_9.customer_id__acquired_ds__year + , subq_9.customer_id__acquired_ds__extract_year + , subq_9.customer_id__acquired_ds__extract_quarter + , subq_9.customer_id__acquired_ds__extract_month + , subq_9.customer_id__acquired_ds__extract_day + , subq_9.customer_id__acquired_ds__extract_dow + , subq_9.customer_id__acquired_ds__extract_doy + , subq_9.customer_third_hop_id__acquired_ds__day + , subq_9.customer_third_hop_id__acquired_ds__week + , subq_9.customer_third_hop_id__acquired_ds__month + , subq_9.customer_third_hop_id__acquired_ds__quarter + , subq_9.customer_third_hop_id__acquired_ds__year + , subq_9.customer_third_hop_id__acquired_ds__extract_year + , subq_9.customer_third_hop_id__acquired_ds__extract_quarter + , subq_9.customer_third_hop_id__acquired_ds__extract_month + , subq_9.customer_third_hop_id__acquired_ds__extract_day + , subq_9.customer_third_hop_id__acquired_ds__extract_dow + , subq_9.customer_third_hop_id__acquired_ds__extract_doy + , subq_9.metric_time__day + , subq_9.metric_time__week + , subq_9.metric_time__month + , subq_9.metric_time__quarter + , subq_9.metric_time__year + , subq_9.metric_time__extract_year + , subq_9.metric_time__extract_quarter + , subq_9.metric_time__extract_month + , subq_9.metric_time__extract_day + , subq_9.metric_time__extract_dow + , subq_9.metric_time__extract_doy + , subq_9.customer_id + , subq_9.customer_third_hop_id + , subq_9.customer_id__customer_third_hop_id + , subq_9.customer_third_hop_id__customer_id + , subq_9.country + , subq_9.customer_id__country + , subq_9.customer_third_hop_id__country FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - subq_26.acquired_ds__day - , subq_26.acquired_ds__week - , subq_26.acquired_ds__month - , subq_26.acquired_ds__quarter - , subq_26.acquired_ds__year - , subq_26.acquired_ds__extract_year - , subq_26.acquired_ds__extract_quarter - , subq_26.acquired_ds__extract_month - , subq_26.acquired_ds__extract_day - , subq_26.acquired_ds__extract_dow - , subq_26.acquired_ds__extract_doy - , subq_26.customer_id__acquired_ds__day - , subq_26.customer_id__acquired_ds__week - , subq_26.customer_id__acquired_ds__month - , subq_26.customer_id__acquired_ds__quarter - , subq_26.customer_id__acquired_ds__year - , subq_26.customer_id__acquired_ds__extract_year - , subq_26.customer_id__acquired_ds__extract_quarter - , subq_26.customer_id__acquired_ds__extract_month - , subq_26.customer_id__acquired_ds__extract_day - , subq_26.customer_id__acquired_ds__extract_dow - , subq_26.customer_id__acquired_ds__extract_doy - , subq_26.customer_third_hop_id__acquired_ds__day - , subq_26.customer_third_hop_id__acquired_ds__week - , subq_26.customer_third_hop_id__acquired_ds__month - , subq_26.customer_third_hop_id__acquired_ds__quarter - , subq_26.customer_third_hop_id__acquired_ds__year - , subq_26.customer_third_hop_id__acquired_ds__extract_year - , subq_26.customer_third_hop_id__acquired_ds__extract_quarter - , subq_26.customer_third_hop_id__acquired_ds__extract_month - , subq_26.customer_third_hop_id__acquired_ds__extract_day - , subq_26.customer_third_hop_id__acquired_ds__extract_dow - , subq_26.customer_third_hop_id__acquired_ds__extract_doy - , subq_26.acquired_ds__day AS metric_time__day - , subq_26.acquired_ds__week AS metric_time__week - , subq_26.acquired_ds__month AS metric_time__month - , subq_26.acquired_ds__quarter AS metric_time__quarter - , subq_26.acquired_ds__year AS metric_time__year - , subq_26.acquired_ds__extract_year AS metric_time__extract_year - , subq_26.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_26.acquired_ds__extract_month AS metric_time__extract_month - , subq_26.acquired_ds__extract_day AS metric_time__extract_day - , subq_26.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_26.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_26.customer_id - , subq_26.customer_third_hop_id - , subq_26.customer_id__customer_third_hop_id - , subq_26.customer_third_hop_id__customer_id - , subq_26.country - , subq_26.customer_id__country - , subq_26.customer_third_hop_id__country - , subq_26.customers_with_other_data + subq_8.acquired_ds__day + , subq_8.acquired_ds__week + , subq_8.acquired_ds__month + , subq_8.acquired_ds__quarter + , subq_8.acquired_ds__year + , subq_8.acquired_ds__extract_year + , subq_8.acquired_ds__extract_quarter + , subq_8.acquired_ds__extract_month + , subq_8.acquired_ds__extract_day + , subq_8.acquired_ds__extract_dow + , subq_8.acquired_ds__extract_doy + , subq_8.customer_id__acquired_ds__day + , subq_8.customer_id__acquired_ds__week + , subq_8.customer_id__acquired_ds__month + , subq_8.customer_id__acquired_ds__quarter + , subq_8.customer_id__acquired_ds__year + , subq_8.customer_id__acquired_ds__extract_year + , subq_8.customer_id__acquired_ds__extract_quarter + , subq_8.customer_id__acquired_ds__extract_month + , subq_8.customer_id__acquired_ds__extract_day + , subq_8.customer_id__acquired_ds__extract_dow + , subq_8.customer_id__acquired_ds__extract_doy + , subq_8.customer_third_hop_id__acquired_ds__day + , subq_8.customer_third_hop_id__acquired_ds__week + , subq_8.customer_third_hop_id__acquired_ds__month + , subq_8.customer_third_hop_id__acquired_ds__quarter + , subq_8.customer_third_hop_id__acquired_ds__year + , subq_8.customer_third_hop_id__acquired_ds__extract_year + , subq_8.customer_third_hop_id__acquired_ds__extract_quarter + , subq_8.customer_third_hop_id__acquired_ds__extract_month + , subq_8.customer_third_hop_id__acquired_ds__extract_day + , subq_8.customer_third_hop_id__acquired_ds__extract_dow + , subq_8.customer_third_hop_id__acquired_ds__extract_doy + , subq_8.acquired_ds__day AS metric_time__day + , subq_8.acquired_ds__week AS metric_time__week + , subq_8.acquired_ds__month AS metric_time__month + , subq_8.acquired_ds__quarter AS metric_time__quarter + , subq_8.acquired_ds__year AS metric_time__year + , subq_8.acquired_ds__extract_year AS metric_time__extract_year + , subq_8.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_8.acquired_ds__extract_month AS metric_time__extract_month + , subq_8.acquired_ds__extract_day AS metric_time__extract_day + , subq_8.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_8.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_8.customer_id + , subq_8.customer_third_hop_id + , subq_8.customer_id__customer_third_hop_id + , subq_8.customer_third_hop_id__customer_id + , subq_8.country + , subq_8.customer_id__country + , subq_8.customer_third_hop_id__country + , subq_8.customers_with_other_data FROM ( -- Read Elements From Semantic Model 'customer_other_data' SELECT @@ -664,31 +664,31 @@ 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_26 - ) subq_27 - ) subq_28 + ) subq_8 + ) subq_9 + ) subq_10 ON - subq_25.customer_id = subq_28.customer_id - ) subq_29 - ) subq_30 + subq_7.customer_id = subq_10.customer_id + ) subq_11 + ) subq_12 ON ( - subq_23.account_id = subq_30.account_id + subq_5.account_id = subq_12.account_id ) AND ( - subq_23.ds_partitioned__day = subq_30.ds_partitioned__day + subq_5.ds_partitioned__day = subq_12.ds_partitioned__day ) - ) subq_31 - ) subq_32 + ) subq_13 + ) subq_14 GROUP BY - subq_32.account_id__customer_id__customer_third_hop_id - ) subq_33 - ) subq_34 - ) subq_35 + subq_14.account_id__customer_id__customer_third_hop_id + ) subq_15 + ) subq_16 + ) subq_17 ON - subq_20.customer_third_hop_id = subq_35.account_id__customer_id__customer_third_hop_id - ) subq_36 - ) subq_37 + subq_2.customer_third_hop_id = subq_17.account_id__customer_id__customer_third_hop_id + ) subq_18 + ) subq_19 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 - ) subq_38 - ) subq_39 -) subq_40 + ) subq_20 + ) subq_21 +) subq_22 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_multi_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_multi_hop__plan0_optimized.sql index bf66de5356..97117da92a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_multi_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_multi_hop__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_76.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + subq_40.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count , 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 ( @@ -18,7 +18,7 @@ FROM ( -- Compute Metrics via Expressions -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_71.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + subq_35.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id , SUM(account_month_txns_src_22000.txn_count) AS account_id__customer_id__customer_third_hop_id__txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -33,17 +33,17 @@ FROM ( ***************************.customer_other_data customer_other_data_src_22000 ON bridge_table_src_22000.customer_id = customer_other_data_src_22000.customer_id - ) subq_71 + ) subq_35 ON ( - account_month_txns_src_22000.account_id = subq_71.account_id + account_month_txns_src_22000.account_id = subq_35.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_71.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_35.ds_partitioned__day ) GROUP BY - subq_71.customer_id__customer_third_hop_id - ) subq_76 + subq_35.customer_id__customer_third_hop_id + ) subq_40 ON - third_hop_table_src_22000.customer_third_hop_id = subq_76.account_id__customer_id__customer_third_hop_id -) subq_78 + third_hop_table_src_22000.customer_third_hop_id = subq_40.account_id__customer_id__customer_third_hop_id +) subq_42 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_single_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_single_hop__plan0.sql index 10fba73707..a688ace075 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_single_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_single_hop__plan0.sql @@ -1,76 +1,76 @@ -- Compute Metrics via Expressions SELECT - subq_25.third_hop_count + subq_16.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_24.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_15.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_23.third_hop_count + subq_14.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_22.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_22.third_hop_count + subq_13.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_13.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_21.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_21.third_hop_count + subq_12.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_12.third_hop_count FROM ( -- Join Standard Outputs SELECT - 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 + subq_2.customer_third_hop_id AS customer_third_hop_id + , subq_11.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_11.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_2.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_10.customer_third_hop_id - , subq_10.third_hop_count + subq_1.customer_third_hop_id + , subq_1.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - 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 + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.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_9 - ) subq_10 - ) subq_11 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_19.customer_id__customer_third_hop_id - , subq_19.customer_id__customer_third_hop_id__paraguayan_customers + subq_10.customer_id__customer_third_hop_id + , subq_10.customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Compute Metrics via Expressions SELECT - subq_18.customer_id__customer_third_hop_id - , subq_18.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_9.customer_id__customer_third_hop_id + , subq_9.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Aggregate Measures SELECT - subq_17.customer_id__customer_third_hop_id - , SUM(subq_17.customers_with_other_data) AS customers_with_other_data + subq_8.customer_id__customer_third_hop_id + , SUM(subq_8.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_16.customer_id__customer_third_hop_id - , subq_16.customers_with_other_data + subq_7.customer_id__customer_third_hop_id + , subq_7.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_15.customer_id__customer_third_hop_id - , subq_15.customer_id__country - , subq_15.customers_with_other_data + subq_6.customer_id__customer_third_hop_id + , subq_6.customer_id__country + , subq_6.customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT - subq_14.customer_id__customer_third_hop_id - , subq_14.customer_id__country - , subq_14.customers_with_other_data + subq_5.customer_id__customer_third_hop_id + , subq_5.customer_id__country + , subq_5.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - 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 + subq_4.acquired_ds__day + , subq_4.acquired_ds__week + , subq_4.acquired_ds__month + , subq_4.acquired_ds__quarter + , subq_4.acquired_ds__year + , subq_4.acquired_ds__extract_year + , subq_4.acquired_ds__extract_quarter + , subq_4.acquired_ds__extract_month + , subq_4.acquired_ds__extract_day + , subq_4.acquired_ds__extract_dow + , subq_4.acquired_ds__extract_doy + , subq_4.customer_id__acquired_ds__day + , subq_4.customer_id__acquired_ds__week + , subq_4.customer_id__acquired_ds__month + , subq_4.customer_id__acquired_ds__quarter + , subq_4.customer_id__acquired_ds__year + , subq_4.customer_id__acquired_ds__extract_year + , subq_4.customer_id__acquired_ds__extract_quarter + , subq_4.customer_id__acquired_ds__extract_month + , subq_4.customer_id__acquired_ds__extract_day + , subq_4.customer_id__acquired_ds__extract_dow + , subq_4.customer_id__acquired_ds__extract_doy + , subq_4.customer_third_hop_id__acquired_ds__day + , subq_4.customer_third_hop_id__acquired_ds__week + , subq_4.customer_third_hop_id__acquired_ds__month + , subq_4.customer_third_hop_id__acquired_ds__quarter + , subq_4.customer_third_hop_id__acquired_ds__year + , subq_4.customer_third_hop_id__acquired_ds__extract_year + , subq_4.customer_third_hop_id__acquired_ds__extract_quarter + , subq_4.customer_third_hop_id__acquired_ds__extract_month + , subq_4.customer_third_hop_id__acquired_ds__extract_day + , subq_4.customer_third_hop_id__acquired_ds__extract_dow + , subq_4.customer_third_hop_id__acquired_ds__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.customer_id + , subq_4.customer_third_hop_id + , subq_4.customer_id__customer_third_hop_id + , subq_4.customer_third_hop_id__customer_id + , subq_4.country + , subq_4.customer_id__country + , subq_4.customer_third_hop_id__country + , subq_4.customers_with_other_data FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - 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 + subq_3.acquired_ds__day + , subq_3.acquired_ds__week + , subq_3.acquired_ds__month + , subq_3.acquired_ds__quarter + , subq_3.acquired_ds__year + , subq_3.acquired_ds__extract_year + , subq_3.acquired_ds__extract_quarter + , subq_3.acquired_ds__extract_month + , subq_3.acquired_ds__extract_day + , subq_3.acquired_ds__extract_dow + , subq_3.acquired_ds__extract_doy + , subq_3.customer_id__acquired_ds__day + , subq_3.customer_id__acquired_ds__week + , subq_3.customer_id__acquired_ds__month + , subq_3.customer_id__acquired_ds__quarter + , subq_3.customer_id__acquired_ds__year + , subq_3.customer_id__acquired_ds__extract_year + , subq_3.customer_id__acquired_ds__extract_quarter + , subq_3.customer_id__acquired_ds__extract_month + , subq_3.customer_id__acquired_ds__extract_day + , subq_3.customer_id__acquired_ds__extract_dow + , subq_3.customer_id__acquired_ds__extract_doy + , subq_3.customer_third_hop_id__acquired_ds__day + , subq_3.customer_third_hop_id__acquired_ds__week + , subq_3.customer_third_hop_id__acquired_ds__month + , subq_3.customer_third_hop_id__acquired_ds__quarter + , subq_3.customer_third_hop_id__acquired_ds__year + , subq_3.customer_third_hop_id__acquired_ds__extract_year + , subq_3.customer_third_hop_id__acquired_ds__extract_quarter + , subq_3.customer_third_hop_id__acquired_ds__extract_month + , subq_3.customer_third_hop_id__acquired_ds__extract_day + , subq_3.customer_third_hop_id__acquired_ds__extract_dow + , subq_3.customer_third_hop_id__acquired_ds__extract_doy + , subq_3.acquired_ds__day AS metric_time__day + , subq_3.acquired_ds__week AS metric_time__week + , subq_3.acquired_ds__month AS metric_time__month + , subq_3.acquired_ds__quarter AS metric_time__quarter + , subq_3.acquired_ds__year AS metric_time__year + , subq_3.acquired_ds__extract_year AS metric_time__extract_year + , subq_3.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_3.acquired_ds__extract_month AS metric_time__extract_month + , subq_3.acquired_ds__extract_day AS metric_time__extract_day + , subq_3.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_3.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_3.customer_id + , subq_3.customer_third_hop_id + , subq_3.customer_id__customer_third_hop_id + , subq_3.customer_third_hop_id__customer_id + , subq_3.country + , subq_3.customer_id__country + , subq_3.customer_third_hop_id__country + , subq_3.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_12 - ) subq_13 + ) subq_3 + ) subq_4 WHERE customer_id__country = 'paraguay' - ) subq_14 - ) subq_15 + ) subq_5 + ) subq_6 WHERE customer_id__country = 'paraguay' - ) subq_16 - ) subq_17 + ) subq_7 + ) subq_8 GROUP BY - subq_17.customer_id__customer_third_hop_id - ) subq_18 - ) subq_19 - ) subq_20 + subq_8.customer_id__customer_third_hop_id + ) subq_9 + ) subq_10 + ) subq_11 ON - subq_11.customer_third_hop_id = subq_20.customer_id__customer_third_hop_id - ) subq_21 - ) subq_22 + subq_2.customer_third_hop_id = subq_11.customer_id__customer_third_hop_id + ) subq_12 + ) subq_13 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_23 - ) subq_24 -) subq_25 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_single_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_single_hop__plan0_optimized.sql index 0fd2bf1820..b73c99c9a9 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_single_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/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_46.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_28.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_39 + ) subq_21 WHERE customer_id__country = 'paraguay' - ) subq_41 + ) subq_23 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_46 + ) subq_28 ON - third_hop_table_src_22000.customer_third_hop_id = subq_46.customer_id__customer_third_hop_id -) subq_48 + third_hop_table_src_22000.customer_third_hop_id = subq_28.customer_id__customer_third_hop_id +) subq_30 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_filtered_by_itself__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_filtered_by_itself__plan0.sql index 32af484217..52e3493f58 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_filtered_by_itself__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_filtered_by_itself__plan0.sql @@ -1,136 +1,136 @@ -- Compute Metrics via Expressions SELECT - subq_17.bookers + subq_13.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_16.bookers) AS bookers + COUNT(DISTINCT subq_12.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_15.bookers + subq_11.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_14.listing__bookers - , subq_14.bookers + subq_10.listing__bookers + , subq_10.bookers FROM ( -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_13.listing__bookers - , subq_13.bookers + subq_9.listing__bookers + , subq_9.bookers FROM ( -- Join Standard Outputs SELECT - subq_6.listing AS listing - , subq_12.listing__bookers AS listing__bookers - , subq_6.bookers AS bookers + subq_2.listing AS listing + , subq_8.listing__bookers AS listing__bookers + , subq_2.bookers AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_5.listing - , subq_5.bookers + subq_1.listing + , subq_1.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -223,130 +223,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookers'] SELECT - subq_11.listing - , subq_11.listing__bookers + subq_7.listing + , subq_7.listing__bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookers AS listing__bookers + subq_6.listing + , subq_6.bookers AS listing__bookers FROM ( -- Aggregate Measures SELECT - subq_9.listing - , COUNT(DISTINCT subq_9.bookers) AS bookers + subq_5.listing + , COUNT(DISTINCT subq_5.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_8.listing - , subq_8.bookers + subq_4.listing + , subq_4.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -439,19 +439,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.listing - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookers > 1.00 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_filtered_by_itself__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_filtered_by_itself__plan0_optimized.sql index e5c7db19a1..fc6f75f09e 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_filtered_by_itself__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_filtered_by_itself__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_30.listing__bookers AS listing__bookers - , subq_24.bookers AS bookers + subq_22.listing__bookers AS listing__bookers + , subq_16.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookers > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_with_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_with_metric_in_where_filter__plan0.sql index 1d01cf449d..6cb487ea46 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_with_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_with_metric_in_where_filter__plan0.sql @@ -1,112 +1,112 @@ -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day - , subq_17.listings AS active_listings + subq_13.metric_time__day + , subq_13.listings AS active_listings FROM ( -- Aggregate Measures SELECT - subq_16.metric_time__day - , SUM(subq_16.listings) AS listings + subq_12.metric_time__day + , SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day'] SELECT - subq_15.metric_time__day - , subq_15.listings + subq_11.metric_time__day + , subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.metric_time__day - , subq_14.listing__bookings - , subq_14.listings + subq_10.metric_time__day + , subq_10.listing__bookings + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_13.metric_time__day - , subq_13.listing__bookings - , subq_13.listings + subq_9.metric_time__day + , subq_9.listing__bookings + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.metric_time__day AS metric_time__day - , subq_6.listing AS listing - , subq_12.listing__bookings AS listing__bookings - , subq_6.listings AS listings + subq_2.metric_time__day AS metric_time__day + , subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] SELECT - subq_5.metric_time__day - , subq_5.listing - , subq_5.listings + subq_1.metric_time__day + , subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -167,130 +167,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_11.listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing - , SUM(subq_9.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_8.listing - , subq_8.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -383,21 +383,21 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.listing - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookings > 2 - ) subq_15 - ) subq_16 + ) subq_11 + ) subq_12 GROUP BY - subq_16.metric_time__day -) subq_17 + subq_12.metric_time__day +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_with_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_with_metric_in_where_filter__plan0_optimized.sql index a43cba6c94..21fd1f7db3 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_with_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_with_metric_in_where_filter__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_24.metric_time__day AS metric_time__day - , subq_30.listing__bookings AS listing__bookings - , subq_24.listings AS listings + subq_16.metric_time__day AS metric_time__day + , subq_22.listing__bookings AS listing__bookings + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -21,7 +21,7 @@ FROM ( , listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -37,13 +37,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_27 + ) subq_19 GROUP BY listing - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookings > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_cumulative_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_cumulative_metric_in_where_filter__plan0.sql index 012e339d10..55ff637b8f 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_cumulative_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_cumulative_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_17.listings + subq_13.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_16.listings) AS listings + SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_15.listings + subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.user__revenue_all_time - , subq_14.listings + subq_10.user__revenue_all_time + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_13.user__revenue_all_time - , subq_13.listings + subq_9.user__revenue_all_time + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.user AS user - , subq_12.user__revenue_all_time AS user__revenue_all_time - , subq_6.listings AS listings + subq_2.user AS user + , subq_8.user__revenue_all_time AS user__revenue_all_time + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_5.user - , subq_5.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,68 +160,68 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user', 'user__revenue_all_time'] SELECT - subq_11.user - , subq_11.user__revenue_all_time + subq_7.user + , subq_7.user__revenue_all_time FROM ( -- Compute Metrics via Expressions SELECT - subq_10.user - , subq_10.txn_revenue AS user__revenue_all_time + subq_6.user + , subq_6.txn_revenue AS user__revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_9.user - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_5.user + , SUM(subq_5.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'user'] SELECT - subq_8.user - , subq_8.txn_revenue + subq_4.user + , subq_4.txn_revenue FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.revenue_instance__ds__day - , subq_7.revenue_instance__ds__week - , subq_7.revenue_instance__ds__month - , subq_7.revenue_instance__ds__quarter - , subq_7.revenue_instance__ds__year - , subq_7.revenue_instance__ds__extract_year - , subq_7.revenue_instance__ds__extract_quarter - , subq_7.revenue_instance__ds__extract_month - , subq_7.revenue_instance__ds__extract_day - , subq_7.revenue_instance__ds__extract_dow - , subq_7.revenue_instance__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.revenue_instance__user - , subq_7.txn_revenue + 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.revenue_instance__ds__day + , subq_3.revenue_instance__ds__week + , subq_3.revenue_instance__ds__month + , subq_3.revenue_instance__ds__quarter + , subq_3.revenue_instance__ds__year + , subq_3.revenue_instance__ds__extract_year + , subq_3.revenue_instance__ds__extract_quarter + , subq_3.revenue_instance__ds__extract_month + , subq_3.revenue_instance__ds__extract_day + , subq_3.revenue_instance__ds__extract_dow + , subq_3.revenue_instance__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_3.user + , subq_3.revenue_instance__user + , subq_3.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -251,19 +251,19 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.user - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.user + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.user = subq_12.user - ) subq_13 - ) subq_14 + subq_2.user = subq_8.user + ) subq_9 + ) subq_10 WHERE user__revenue_all_time > 1 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql index 4f006f13ed..2b782589e8 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_30.user__revenue_all_time AS user__revenue_all_time - , subq_24.listings AS listings + subq_22.user__revenue_all_time AS user__revenue_all_time + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_revenue revenue_src_28000 GROUP BY user_id - ) subq_30 + ) subq_22 ON - subq_24.user = subq_30.user -) subq_32 + subq_16.user = subq_22.user +) subq_24 WHERE user__revenue_all_time > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_derived_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_derived_metric_in_where_filter__plan0.sql index a8ce477fc6..670d846141 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_derived_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_derived_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_31.listings + subq_20.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_30.listings) AS listings + SUM(subq_19.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_29.listings + subq_18.listings FROM ( -- Constrain Output with WHERE SELECT - subq_28.listing__views_times_booking_value - , subq_28.listings + subq_17.listing__views_times_booking_value + , subq_17.listings FROM ( -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_27.listing__views_times_booking_value - , subq_27.listings + subq_16.listing__views_times_booking_value + , subq_16.listings FROM ( -- Join Standard Outputs SELECT - subq_13.listing AS listing - , subq_26.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_13.listings AS listings + subq_2.listing AS listing + , subq_15.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_12.listing - , subq_12.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,141 +160,141 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] SELECT - subq_25.listing - , subq_25.listing__views_times_booking_value + subq_14.listing + , subq_14.listing__views_times_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_24.listing + subq_13.listing , booking_value * views AS listing__views_times_booking_value FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.listing, subq_23.listing) AS listing - , MAX(subq_18.booking_value) AS booking_value - , MAX(subq_23.views) AS views + COALESCE(subq_7.listing, subq_12.listing) AS listing + , MAX(subq_7.booking_value) AS booking_value + , MAX(subq_12.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_17.listing - , subq_17.booking_value + subq_6.listing + , subq_6.booking_value FROM ( -- Aggregate Measures SELECT - subq_16.listing - , SUM(subq_16.booking_value) AS booking_value + subq_5.listing + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'listing'] SELECT - subq_15.listing - , subq_15.booking_value + subq_4.listing + , subq_4.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_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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -387,91 +387,91 @@ 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_3 + ) subq_4 + ) subq_5 GROUP BY - subq_16.listing - ) subq_17 - ) subq_18 + subq_5.listing + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.listing - , subq_22.views + subq_11.listing + , subq_11.views FROM ( -- Aggregate Measures SELECT - subq_21.listing - , SUM(subq_21.views) AS views + subq_10.listing + , SUM(subq_10.views) AS views FROM ( -- Pass Only Elements: ['views', 'listing'] SELECT - subq_20.listing - , subq_20.views + subq_9.listing + , subq_9.views FROM ( -- Metric Time Dimension 'ds' 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.view__ds__day - , subq_19.view__ds__week - , subq_19.view__ds__month - , subq_19.view__ds__quarter - , subq_19.view__ds__year - , subq_19.view__ds__extract_year - , subq_19.view__ds__extract_quarter - , subq_19.view__ds__extract_month - , subq_19.view__ds__extract_day - , subq_19.view__ds__extract_dow - , subq_19.view__ds__extract_doy - , subq_19.view__ds_partitioned__day - , subq_19.view__ds_partitioned__week - , subq_19.view__ds_partitioned__month - , subq_19.view__ds_partitioned__quarter - , subq_19.view__ds_partitioned__year - , subq_19.view__ds_partitioned__extract_year - , subq_19.view__ds_partitioned__extract_quarter - , subq_19.view__ds_partitioned__extract_month - , subq_19.view__ds_partitioned__extract_day - , subq_19.view__ds_partitioned__extract_dow - , subq_19.view__ds_partitioned__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.user - , subq_19.view__listing - , subq_19.view__user - , subq_19.views + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.view__ds__day + , subq_8.view__ds__week + , subq_8.view__ds__month + , subq_8.view__ds__quarter + , subq_8.view__ds__year + , subq_8.view__ds__extract_year + , subq_8.view__ds__extract_quarter + , subq_8.view__ds__extract_month + , subq_8.view__ds__extract_day + , subq_8.view__ds__extract_dow + , subq_8.view__ds__extract_doy + , subq_8.view__ds_partitioned__day + , subq_8.view__ds_partitioned__week + , subq_8.view__ds_partitioned__month + , subq_8.view__ds_partitioned__quarter + , subq_8.view__ds_partitioned__year + , subq_8.view__ds_partitioned__extract_year + , subq_8.view__ds_partitioned__extract_quarter + , subq_8.view__ds_partitioned__extract_month + , subq_8.view__ds_partitioned__extract_day + , subq_8.view__ds_partitioned__extract_dow + , subq_8.view__ds_partitioned__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.user + , subq_8.view__listing + , subq_8.view__user + , subq_8.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT @@ -525,25 +525,25 @@ FROM ( , views_source_src_28000.listing_id AS view__listing , views_source_src_28000.user_id AS view__user FROM ***************************.fct_views views_source_src_28000 - ) subq_19 - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_21.listing - ) subq_22 - ) subq_23 + subq_10.listing + ) subq_11 + ) subq_12 ON - subq_18.listing = subq_23.listing + subq_7.listing = subq_12.listing GROUP BY - COALESCE(subq_18.listing, subq_23.listing) - ) subq_24 - ) subq_25 - ) subq_26 + COALESCE(subq_7.listing, subq_12.listing) + ) subq_13 + ) subq_14 + ) subq_15 ON - subq_13.listing = subq_26.listing - ) subq_27 - ) subq_28 + subq_2.listing = subq_15.listing + ) subq_16 + ) subq_17 WHERE listing__views_times_booking_value > 1 - ) subq_29 - ) subq_30 -) subq_31 + ) subq_18 + ) subq_19 +) subq_20 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql index f8024b63f1..e5f6bf61fb 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_58.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_45.listings AS listings + subq_36.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_23.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_45 + ) subq_23 LEFT OUTER JOIN ( -- Compute Metrics via Expressions -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] @@ -28,9 +28,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_50.listing, subq_55.listing) AS listing - , MAX(subq_50.booking_value) AS booking_value - , MAX(subq_55.views) AS views + COALESCE(subq_28.listing, subq_33.listing) AS listing + , MAX(subq_28.booking_value) AS booking_value + , MAX(subq_33.views) AS views FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -43,7 +43,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_50 + ) subq_28 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -58,17 +58,17 @@ FROM ( listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_53 + ) subq_31 GROUP BY listing - ) subq_55 + ) subq_33 ON - subq_50.listing = subq_55.listing + subq_28.listing = subq_33.listing GROUP BY - COALESCE(subq_50.listing, subq_55.listing) - ) subq_56 - ) subq_58 + COALESCE(subq_28.listing, subq_33.listing) + ) subq_34 + ) subq_36 ON - subq_45.listing = subq_58.listing -) subq_60 + subq_23.listing = subq_36.listing +) subq_38 WHERE listing__views_times_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_multiple_metrics_in_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_multiple_metrics_in_filter__plan0.sql index 5e10ea03d4..5e03e7bb6b 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_multiple_metrics_in_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_multiple_metrics_in_filter__plan0.sql @@ -1,108 +1,108 @@ -- Compute Metrics via Expressions SELECT - subq_27.listings + subq_19.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_26.listings) AS listings + SUM(subq_18.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_25.listings + subq_17.listings FROM ( -- Constrain Output with WHERE SELECT - subq_24.listing__bookings - , subq_24.listing__bookers - , subq_24.listings + subq_16.listing__bookings + , subq_16.listing__bookers + , subq_16.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_23.listing__bookings - , subq_23.listing__bookers - , subq_23.listings + subq_15.listing__bookings + , subq_15.listing__bookers + , subq_15.listings FROM ( -- Join Standard Outputs SELECT - subq_10.listing AS listing - , subq_16.listing__bookings AS listing__bookings - , subq_22.listing__bookers AS listing__bookers - , subq_10.listings AS listings + subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_14.listing__bookers AS listing__bookers + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing', 'listing'] SELECT - subq_9.listing - , subq_9.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' 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.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , 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.listings - , subq_8.largest_listing - , subq_8.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -163,130 +163,130 @@ 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_8 - ) subq_9 - ) subq_10 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_15.listing - , subq_15.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_13.listing - , SUM(subq_13.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_12.listing - , subq_12.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.paid_at__day - , subq_11.paid_at__week - , subq_11.paid_at__month - , subq_11.paid_at__quarter - , subq_11.paid_at__year - , subq_11.paid_at__extract_year - , subq_11.paid_at__extract_quarter - , subq_11.paid_at__extract_month - , subq_11.paid_at__extract_day - , subq_11.paid_at__extract_dow - , subq_11.paid_at__extract_doy - , subq_11.booking__ds__day - , subq_11.booking__ds__week - , subq_11.booking__ds__month - , subq_11.booking__ds__quarter - , subq_11.booking__ds__year - , subq_11.booking__ds__extract_year - , subq_11.booking__ds__extract_quarter - , subq_11.booking__ds__extract_month - , subq_11.booking__ds__extract_day - , subq_11.booking__ds__extract_dow - , subq_11.booking__ds__extract_doy - , subq_11.booking__ds_partitioned__day - , subq_11.booking__ds_partitioned__week - , subq_11.booking__ds_partitioned__month - , subq_11.booking__ds_partitioned__quarter - , subq_11.booking__ds_partitioned__year - , subq_11.booking__ds_partitioned__extract_year - , subq_11.booking__ds_partitioned__extract_quarter - , subq_11.booking__ds_partitioned__extract_month - , subq_11.booking__ds_partitioned__extract_day - , subq_11.booking__ds_partitioned__extract_dow - , subq_11.booking__ds_partitioned__extract_doy - , subq_11.booking__paid_at__day - , subq_11.booking__paid_at__week - , subq_11.booking__paid_at__month - , subq_11.booking__paid_at__quarter - , subq_11.booking__paid_at__year - , subq_11.booking__paid_at__extract_year - , subq_11.booking__paid_at__extract_quarter - , subq_11.booking__paid_at__extract_month - , subq_11.booking__paid_at__extract_day - , subq_11.booking__paid_at__extract_dow - , subq_11.booking__paid_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.guest - , subq_11.host - , subq_11.booking__listing - , subq_11.booking__guest - , subq_11.booking__host - , subq_11.is_instant - , subq_11.booking__is_instant - , subq_11.bookings - , subq_11.instant_bookings - , subq_11.booking_value - , subq_11.max_booking_value - , subq_11.min_booking_value - , subq_11.bookers - , subq_11.average_booking_value - , subq_11.referred_bookings - , subq_11.median_booking_value - , subq_11.booking_value_p99 - , subq_11.discrete_booking_value_p99 - , subq_11.approximate_continuous_booking_value_p99 - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -379,137 +379,137 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_13.listing - ) subq_14 - ) subq_15 - ) subq_16 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_10.listing = subq_16.listing + subq_2.listing = subq_8.listing LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookers'] SELECT - subq_21.listing - , subq_21.listing__bookers + subq_13.listing + , subq_13.listing__bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_20.listing - , subq_20.bookers AS listing__bookers + subq_12.listing + , subq_12.bookers AS listing__bookers FROM ( -- Aggregate Measures SELECT - subq_19.listing - , COUNT(DISTINCT subq_19.bookers) AS bookers + subq_11.listing + , COUNT(DISTINCT subq_11.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_18.listing - , subq_18.bookers + subq_10.listing + , subq_10.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_17.ds__day - , subq_17.ds__week - , subq_17.ds__month - , subq_17.ds__quarter - , subq_17.ds__year - , subq_17.ds__extract_year - , subq_17.ds__extract_quarter - , subq_17.ds__extract_month - , subq_17.ds__extract_day - , subq_17.ds__extract_dow - , subq_17.ds__extract_doy - , subq_17.ds_partitioned__day - , subq_17.ds_partitioned__week - , subq_17.ds_partitioned__month - , subq_17.ds_partitioned__quarter - , subq_17.ds_partitioned__year - , subq_17.ds_partitioned__extract_year - , subq_17.ds_partitioned__extract_quarter - , subq_17.ds_partitioned__extract_month - , subq_17.ds_partitioned__extract_day - , subq_17.ds_partitioned__extract_dow - , subq_17.ds_partitioned__extract_doy - , subq_17.paid_at__day - , subq_17.paid_at__week - , subq_17.paid_at__month - , subq_17.paid_at__quarter - , subq_17.paid_at__year - , subq_17.paid_at__extract_year - , subq_17.paid_at__extract_quarter - , subq_17.paid_at__extract_month - , subq_17.paid_at__extract_day - , subq_17.paid_at__extract_dow - , subq_17.paid_at__extract_doy - , subq_17.booking__ds__day - , subq_17.booking__ds__week - , subq_17.booking__ds__month - , subq_17.booking__ds__quarter - , subq_17.booking__ds__year - , subq_17.booking__ds__extract_year - , subq_17.booking__ds__extract_quarter - , subq_17.booking__ds__extract_month - , subq_17.booking__ds__extract_day - , subq_17.booking__ds__extract_dow - , subq_17.booking__ds__extract_doy - , subq_17.booking__ds_partitioned__day - , subq_17.booking__ds_partitioned__week - , subq_17.booking__ds_partitioned__month - , subq_17.booking__ds_partitioned__quarter - , subq_17.booking__ds_partitioned__year - , subq_17.booking__ds_partitioned__extract_year - , subq_17.booking__ds_partitioned__extract_quarter - , subq_17.booking__ds_partitioned__extract_month - , subq_17.booking__ds_partitioned__extract_day - , subq_17.booking__ds_partitioned__extract_dow - , subq_17.booking__ds_partitioned__extract_doy - , subq_17.booking__paid_at__day - , subq_17.booking__paid_at__week - , subq_17.booking__paid_at__month - , subq_17.booking__paid_at__quarter - , subq_17.booking__paid_at__year - , subq_17.booking__paid_at__extract_year - , subq_17.booking__paid_at__extract_quarter - , subq_17.booking__paid_at__extract_month - , subq_17.booking__paid_at__extract_day - , subq_17.booking__paid_at__extract_dow - , subq_17.booking__paid_at__extract_doy - , subq_17.ds__day AS metric_time__day - , subq_17.ds__week AS metric_time__week - , subq_17.ds__month AS metric_time__month - , subq_17.ds__quarter AS metric_time__quarter - , subq_17.ds__year AS metric_time__year - , subq_17.ds__extract_year AS metric_time__extract_year - , subq_17.ds__extract_quarter AS metric_time__extract_quarter - , subq_17.ds__extract_month AS metric_time__extract_month - , subq_17.ds__extract_day AS metric_time__extract_day - , subq_17.ds__extract_dow AS metric_time__extract_dow - , subq_17.ds__extract_doy AS metric_time__extract_doy - , subq_17.listing - , subq_17.guest - , subq_17.host - , subq_17.booking__listing - , subq_17.booking__guest - , subq_17.booking__host - , subq_17.is_instant - , subq_17.booking__is_instant - , subq_17.bookings - , subq_17.instant_bookings - , subq_17.booking_value - , subq_17.max_booking_value - , subq_17.min_booking_value - , subq_17.bookers - , subq_17.average_booking_value - , subq_17.referred_bookings - , subq_17.median_booking_value - , subq_17.booking_value_p99 - , subq_17.discrete_booking_value_p99 - , subq_17.approximate_continuous_booking_value_p99 - , subq_17.approximate_discrete_booking_value_p99 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -602,19 +602,19 @@ 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_17 - ) subq_18 - ) subq_19 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_19.listing - ) subq_20 - ) subq_21 - ) subq_22 + subq_11.listing + ) subq_12 + ) subq_13 + ) subq_14 ON - subq_10.listing = subq_22.listing - ) subq_23 - ) subq_24 + subq_2.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__bookings > 2 AND listing__bookers > 1 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql index 1846b78cd5..767f0b3fea 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_44.listing__bookings AS listing__bookings - , subq_50.listing__bookers AS listing__bookers - , subq_38.listings AS listings + subq_28.listing__bookings AS listing__bookings + , subq_34.listing__bookers AS listing__bookers + , subq_22.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -19,7 +19,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_38 + ) subq_22 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,12 +35,12 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_41 + ) subq_25 GROUP BY listing - ) subq_44 + ) subq_28 ON - subq_38.listing = subq_44.listing + subq_22.listing = subq_28.listing LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -54,8 +54,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_50 + ) subq_34 ON - subq_38.listing = subq_50.listing -) subq_52 + subq_22.listing = subq_34.listing +) subq_36 WHERE listing__bookings > 2 AND listing__bookers > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_ratio_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_ratio_metric_in_where_filter__plan0.sql index 90bd1fd2e4..9d9e2daf1b 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_ratio_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_ratio_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_31.listings + subq_20.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_30.listings) AS listings + SUM(subq_19.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_29.listings + subq_18.listings FROM ( -- Constrain Output with WHERE SELECT - subq_28.listing__bookings_per_booker - , subq_28.listings + subq_17.listing__bookings_per_booker + , subq_17.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - subq_27.listing__bookings_per_booker - , subq_27.listings + subq_16.listing__bookings_per_booker + , subq_16.listings FROM ( -- Join Standard Outputs SELECT - subq_13.listing AS listing - , subq_26.listing__bookings_per_booker AS listing__bookings_per_booker - , subq_13.listings AS listings + subq_2.listing AS listing + , subq_15.listing__bookings_per_booker AS listing__bookings_per_booker + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_12.listing - , subq_12.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,141 +160,141 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] SELECT - subq_25.listing - , subq_25.listing__bookings_per_booker + subq_14.listing + , subq_14.listing__bookings_per_booker FROM ( -- Compute Metrics via Expressions SELECT - subq_24.listing - , CAST(subq_24.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_24.bookers, 0) AS DOUBLE PRECISION) AS listing__bookings_per_booker + subq_13.listing + , CAST(subq_13.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_13.bookers, 0) AS DOUBLE PRECISION) AS listing__bookings_per_booker FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.listing, subq_23.listing) AS listing - , MAX(subq_18.bookings) AS bookings - , MAX(subq_23.bookers) AS bookers + COALESCE(subq_7.listing, subq_12.listing) AS listing + , MAX(subq_7.bookings) AS bookings + , MAX(subq_12.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_17.listing - , subq_17.bookings + subq_6.listing + , subq_6.bookings FROM ( -- Aggregate Measures SELECT - subq_16.listing - , SUM(subq_16.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_15.listing - , subq_15.bookings + subq_4.listing + , subq_4.bookings 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_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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -387,129 +387,129 @@ 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_3 + ) subq_4 + ) subq_5 GROUP BY - subq_16.listing - ) subq_17 - ) subq_18 + subq_5.listing + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.listing - , subq_22.bookers + subq_11.listing + , subq_11.bookers FROM ( -- Aggregate Measures SELECT - subq_21.listing - , COUNT(DISTINCT subq_21.bookers) AS bookers + subq_10.listing + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_20.listing - , subq_20.bookers + subq_9.listing + , subq_9.bookers FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -602,25 +602,25 @@ 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_19 - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_21.listing - ) subq_22 - ) subq_23 + subq_10.listing + ) subq_11 + ) subq_12 ON - subq_18.listing = subq_23.listing + subq_7.listing = subq_12.listing GROUP BY - COALESCE(subq_18.listing, subq_23.listing) - ) subq_24 - ) subq_25 - ) subq_26 + COALESCE(subq_7.listing, subq_12.listing) + ) subq_13 + ) subq_14 + ) subq_15 ON - subq_13.listing = subq_26.listing - ) subq_27 - ) subq_28 + subq_2.listing = subq_15.listing + ) subq_16 + ) subq_17 WHERE listing__bookings_per_booker > 1 - ) subq_29 - ) subq_30 -) subq_31 + ) subq_18 + ) subq_19 +) subq_20 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql index 4047775652..8533e9e31e 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - CAST(subq_56.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_56.bookers, 0) AS DOUBLE PRECISION) AS listing__bookings_per_booker - , subq_45.listings AS listings + CAST(subq_34.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_34.bookers, 0) AS DOUBLE PRECISION) AS listing__bookings_per_booker + , subq_23.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,13 +18,13 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_45 + ) subq_23 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_50.listing, subq_55.listing) AS listing - , MAX(subq_50.bookings) AS bookings - , MAX(subq_55.bookers) AS bookers + COALESCE(subq_28.listing, subq_33.listing) AS listing + , MAX(subq_28.bookings) AS bookings + , MAX(subq_33.bookers) AS bookers FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,10 +39,10 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_48 + ) subq_26 GROUP BY listing - ) subq_50 + ) subq_28 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -55,13 +55,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_55 + ) subq_33 ON - subq_50.listing = subq_55.listing + subq_28.listing = subq_33.listing GROUP BY - COALESCE(subq_50.listing, subq_55.listing) - ) subq_56 + COALESCE(subq_28.listing, subq_33.listing) + ) subq_34 ON - subq_45.listing = subq_56.listing -) subq_60 + subq_23.listing = subq_34.listing +) subq_38 WHERE listing__bookings_per_booker > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_simple_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_simple_metric_in_where_filter__plan0.sql index 3e5c126151..4fadfb17c8 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_simple_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_simple_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_17.listings + subq_13.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_16.listings) AS listings + SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_15.listings + subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.listing__bookings - , subq_14.listings + subq_10.listing__bookings + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_13.listing__bookings - , subq_13.listings + subq_9.listing__bookings + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.listing AS listing - , subq_12.listing__bookings AS listing__bookings - , subq_6.listings AS listings + subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_5.listing - , subq_5.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,130 +160,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_11.listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing - , SUM(subq_9.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_8.listing - , subq_8.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -376,19 +376,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.listing - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookings > 2 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql index 98bdb265dd..48fed36d03 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_30.listing__bookings AS listing__bookings - , subq_24.listings AS listings + subq_22.listing__bookings AS listing__bookings + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -34,11 +34,11 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_27 + ) subq_19 GROUP BY listing - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookings > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values_query_with_metric_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values_query_with_metric_filter__plan0.sql index 5832467cf8..5c91195c37 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values_query_with_metric_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values_query_with_metric_filter__plan0.sql @@ -1,20 +1,20 @@ -- Pass Only Elements: ['listing',] SELECT - subq_12.listing + subq_8.listing FROM ( -- Constrain Output with WHERE SELECT - subq_11.listing - , subq_11.lux_listing - , subq_11.listing__lux_listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.lux_listing + , subq_7.listing__lux_listing + , subq_7.listing__bookings FROM ( -- Join Standard Outputs SELECT - subq_4.listing AS listing - , subq_4.lux_listing AS lux_listing - , subq_4.listing__lux_listing AS listing__lux_listing - , subq_10.listing__bookings AS listing__bookings + subq_0.listing AS listing + , subq_0.lux_listing AS lux_listing + , subq_0.listing__lux_listing AS listing__lux_listing + , subq_6.listing__bookings AS listing__bookings FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -22,128 +22,128 @@ FROM ( , lux_listing_mapping_src_28000.lux_listing_id AS lux_listing , lux_listing_mapping_src_28000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_28000 - ) subq_4 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_9.listing - , subq_9.listing__bookings + subq_5.listing + , subq_5.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.listing - , subq_8.bookings AS listing__bookings + subq_4.listing + , subq_4.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_7.listing - , SUM(subq_7.bookings) AS bookings + subq_3.listing + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_6.listing - , subq_6.bookings + subq_2.listing + , subq_2.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__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 + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -236,18 +236,18 @@ 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_5 - ) subq_6 - ) subq_7 + ) subq_1 + ) subq_2 + ) subq_3 GROUP BY - subq_7.listing - ) subq_8 - ) subq_9 - ) subq_10 + subq_3.listing + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_4.listing = subq_10.listing - ) subq_11 + subq_0.listing = subq_6.listing + ) subq_7 WHERE listing__bookings > 2 -) subq_12 +) subq_8 GROUP BY - subq_12.listing + subq_8.listing diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values_query_with_metric_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values_query_with_metric_filter__plan0_optimized.sql index cde9c960c5..d79ef0aa09 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values_query_with_metric_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values_query_with_metric_filter__plan0_optimized.sql @@ -6,7 +6,7 @@ FROM ( -- Join Standard Outputs SELECT lux_listing_mapping_src_28000.listing_id AS listing - , subq_23.listing__bookings AS listing__bookings + , subq_15.listing__bookings AS listing__bookings FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_28000 FULL OUTER JOIN ( -- Aggregate Measures @@ -23,13 +23,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_20 + ) subq_12 GROUP BY listing - ) subq_23 + ) subq_15 ON - lux_listing_mapping_src_28000.listing_id = subq_23.listing -) subq_24 + lux_listing_mapping_src_28000.listing_id = subq_15.listing +) subq_16 WHERE listing__bookings > 2 GROUP BY listing diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql index fdfc7bdaf8..34d6221739 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql @@ -1,136 +1,136 @@ -- Compute Metrics via Expressions SELECT - subq_17.bookers + subq_13.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_16.bookers) AS bookers + COUNT(DISTINCT subq_12.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_15.bookers + subq_11.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_14.guest__booking_value - , subq_14.bookers + subq_10.guest__booking_value + , subq_10.bookers FROM ( -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_13.guest__booking_value - , subq_13.bookers + subq_9.guest__booking_value + , subq_9.bookers FROM ( -- Join Standard Outputs SELECT - subq_6.guest AS guest - , subq_12.guest__booking_value AS guest__booking_value - , subq_6.bookers AS bookers + subq_2.guest AS guest + , subq_8.guest__booking_value AS guest__booking_value + , subq_2.bookers AS bookers FROM ( -- Pass Only Elements: ['bookers', 'guest'] SELECT - subq_5.guest - , subq_5.bookers + subq_1.guest + , subq_1.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -223,130 +223,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['guest', 'guest__booking_value'] SELECT - subq_11.guest - , subq_11.guest__booking_value + subq_7.guest + , subq_7.guest__booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.guest - , subq_10.booking_value AS guest__booking_value + subq_6.guest + , subq_6.booking_value AS guest__booking_value FROM ( -- Aggregate Measures SELECT - subq_9.guest - , SUM(subq_9.booking_value) AS booking_value + subq_5.guest + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'guest'] SELECT - subq_8.guest - , subq_8.booking_value + subq_4.guest + , subq_4.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -439,19 +439,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.guest - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.guest + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.guest = subq_12.guest - ) subq_13 - ) subq_14 + subq_2.guest = subq_8.guest + ) subq_9 + ) subq_10 WHERE guest__booking_value > 1.00 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql index 7df3ce4738..93d184feee 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_30.guest__booking_value AS guest__booking_value - , subq_24.bookers AS bookers + subq_22.guest__booking_value AS guest__booking_value + , subq_16.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( guest_id AS guest , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY guest_id - ) subq_30 + ) subq_22 ON - subq_24.guest = subq_30.guest -) subq_32 + subq_16.guest = subq_22.guest +) subq_24 WHERE guest__booking_value > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_conversion_metric__plan0.sql index 42675168db..56c39d895f 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_conversion_metric__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_39.listings + subq_24.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_38.listings) AS listings + SUM(subq_23.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_37.listings + subq_22.listings FROM ( -- Constrain Output with WHERE SELECT - subq_36.user__visit_buy_conversion_rate - , subq_36.listings + subq_21.user__visit_buy_conversion_rate + , subq_21.listings FROM ( -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - subq_35.user__visit_buy_conversion_rate - , subq_35.listings + subq_20.user__visit_buy_conversion_rate + , subq_20.listings FROM ( -- Join Standard Outputs SELECT - subq_17.user AS user - , subq_34.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate - , subq_17.listings AS listings + subq_2.user AS user + , subq_19.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_16.user - , subq_16.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,79 +160,79 @@ 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_15 - ) subq_16 - ) subq_17 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] SELECT - subq_33.user - , subq_33.user__visit_buy_conversion_rate + subq_18.user + , subq_18.user__visit_buy_conversion_rate FROM ( -- Compute Metrics via Expressions SELECT - subq_32.user - , CAST(subq_32.buys AS DOUBLE) / CAST(NULLIF(subq_32.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate + subq_17.user + , CAST(subq_17.buys AS DOUBLE) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.user, subq_31.user) AS user - , MAX(subq_21.visits) AS visits - , MAX(subq_31.buys) AS buys + COALESCE(subq_6.user, subq_16.user) AS user + , MAX(subq_6.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_20.user - , SUM(subq_20.visits) AS visits + subq_5.user + , SUM(subq_5.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'user'] SELECT - subq_19.user - , subq_19.visits + subq_4.user + , subq_4.visits 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.visit__ds__day - , subq_18.visit__ds__week - , subq_18.visit__ds__month - , subq_18.visit__ds__quarter - , subq_18.visit__ds__year - , subq_18.visit__ds__extract_year - , subq_18.visit__ds__extract_quarter - , subq_18.visit__ds__extract_month - , subq_18.visit__ds__extract_day - , subq_18.visit__ds__extract_dow - , subq_18.visit__ds__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.user - , subq_18.session - , subq_18.visit__user - , subq_18.visit__session - , subq_18.referrer_id - , subq_18.visit__referrer_id - , subq_18.visits - , subq_18.visitors + 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.visit__ds__day + , subq_3.visit__ds__week + , subq_3.visit__ds__month + , subq_3.visit__ds__quarter + , subq_3.visit__ds__year + , subq_3.visit__ds__extract_year + , subq_3.visit__ds__extract_quarter + , subq_3.visit__ds__extract_month + , subq_3.visit__ds__extract_day + , subq_3.visit__ds__extract_dow + , subq_3.visit__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_3.user + , subq_3.session + , subq_3.visit__user + , subq_3.visit__session + , subq_3.referrer_id + , subq_3.visit__referrer_id + , subq_3.visits + , subq_3.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -267,108 +267,108 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_18 - ) subq_19 - ) subq_20 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_20.user - ) subq_21 + subq_5.user + ) subq_6 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_30.user - , SUM(subq_30.buys) AS buys + subq_15.user + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'user'] SELECT - subq_29.user - , subq_29.buys + subq_14.user + , subq_14.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_28.ds__day - , subq_28.user - , subq_28.buys - , subq_28.visits + subq_13.ds__day + , subq_13.user + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_24.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_24.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_24.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_27.mf_internal_uuid AS mf_internal_uuid - , subq_27.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_23.ds__day - , subq_23.user - , subq_23.visits + subq_8.ds__day + , subq_8.user + , subq_8.visits 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.visit__ds__day - , subq_22.visit__ds__week - , subq_22.visit__ds__month - , subq_22.visit__ds__quarter - , subq_22.visit__ds__year - , subq_22.visit__ds__extract_year - , subq_22.visit__ds__extract_quarter - , subq_22.visit__ds__extract_month - , subq_22.visit__ds__extract_day - , subq_22.visit__ds__extract_dow - , subq_22.visit__ds__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.user - , subq_22.session - , subq_22.visit__user - , subq_22.visit__session - , subq_22.referrer_id - , subq_22.visit__referrer_id - , subq_22.visits - , subq_22.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -403,94 +403,94 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_22 - ) subq_23 - ) subq_24 + ) subq_7 + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_26.ds__day - , subq_26.ds__week - , subq_26.ds__month - , subq_26.ds__quarter - , subq_26.ds__year - , subq_26.ds__extract_year - , subq_26.ds__extract_quarter - , subq_26.ds__extract_month - , subq_26.ds__extract_day - , subq_26.ds__extract_dow - , subq_26.ds__extract_doy - , subq_26.buy__ds__day - , subq_26.buy__ds__week - , subq_26.buy__ds__month - , subq_26.buy__ds__quarter - , subq_26.buy__ds__year - , subq_26.buy__ds__extract_year - , subq_26.buy__ds__extract_quarter - , subq_26.buy__ds__extract_month - , subq_26.buy__ds__extract_day - , subq_26.buy__ds__extract_dow - , subq_26.buy__ds__extract_doy - , subq_26.metric_time__day - , subq_26.metric_time__week - , subq_26.metric_time__month - , subq_26.metric_time__quarter - , subq_26.metric_time__year - , subq_26.metric_time__extract_year - , subq_26.metric_time__extract_quarter - , subq_26.metric_time__extract_month - , subq_26.metric_time__extract_day - , subq_26.metric_time__extract_dow - , subq_26.metric_time__extract_doy - , subq_26.user - , subq_26.session_id - , subq_26.buy__user - , subq_26.buy__session_id - , subq_26.buys - , subq_26.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , UUID_STRING() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_25.ds__day - , subq_25.ds__week - , subq_25.ds__month - , subq_25.ds__quarter - , subq_25.ds__year - , subq_25.ds__extract_year - , subq_25.ds__extract_quarter - , subq_25.ds__extract_month - , subq_25.ds__extract_day - , subq_25.ds__extract_dow - , subq_25.ds__extract_doy - , subq_25.buy__ds__day - , subq_25.buy__ds__week - , subq_25.buy__ds__month - , subq_25.buy__ds__quarter - , subq_25.buy__ds__year - , subq_25.buy__ds__extract_year - , subq_25.buy__ds__extract_quarter - , subq_25.buy__ds__extract_month - , subq_25.buy__ds__extract_day - , subq_25.buy__ds__extract_dow - , subq_25.buy__ds__extract_doy - , subq_25.ds__day AS metric_time__day - , subq_25.ds__week AS metric_time__week - , subq_25.ds__month AS metric_time__month - , subq_25.ds__quarter AS metric_time__quarter - , subq_25.ds__year AS metric_time__year - , subq_25.ds__extract_year AS metric_time__extract_year - , subq_25.ds__extract_quarter AS metric_time__extract_quarter - , subq_25.ds__extract_month AS metric_time__extract_month - , subq_25.ds__extract_day AS metric_time__extract_day - , subq_25.ds__extract_dow AS metric_time__extract_dow - , subq_25.ds__extract_doy AS metric_time__extract_doy - , subq_25.user - , subq_25.session_id - , subq_25.buy__user - , subq_25.buy__session_id - , subq_25.buys - , subq_25.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -523,33 +523,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_25 - ) subq_26 - ) subq_27 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_24.user = subq_27.user + subq_9.user = subq_12.user ) AND ( - (subq_24.ds__day <= subq_27.ds__day) + (subq_9.ds__day <= subq_12.ds__day) ) - ) subq_28 - ) subq_29 - ) subq_30 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY - subq_30.user - ) subq_31 + subq_15.user + ) subq_16 ON - subq_21.user = subq_31.user + subq_6.user = subq_16.user GROUP BY - COALESCE(subq_21.user, subq_31.user) - ) subq_32 - ) subq_33 - ) subq_34 + COALESCE(subq_6.user, subq_16.user) + ) subq_17 + ) subq_18 + ) subq_19 ON - subq_17.user = subq_34.user - ) subq_35 - ) subq_36 + subq_2.user = subq_19.user + ) subq_20 + ) subq_21 WHERE user__visit_buy_conversion_rate > 2 - ) subq_37 - ) subq_38 -) subq_39 + ) subq_22 + ) subq_23 +) subq_24 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_conversion_metric__plan0_optimized.sql index e3715e504d..32a2c7c99e 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_conversion_metric__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - CAST(subq_72.buys AS DOUBLE) / CAST(NULLIF(subq_72.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate - , subq_57.listings AS listings + CAST(subq_42.buys AS DOUBLE) / CAST(NULLIF(subq_42.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate + , subq_27.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,17 +18,17 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_57 + ) subq_27 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_61.user, subq_71.user) AS user - , MAX(subq_61.visits) AS visits - , MAX(subq_71.buys) AS buys + COALESCE(subq_31.user, subq_41.user) AS user + , MAX(subq_31.visits) AS visits + , MAX(subq_41.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_60.user + subq_30.user , SUM(visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -38,46 +38,46 @@ FROM ( user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_60 + ) subq_30 GROUP BY - subq_60.user - ) subq_61 + subq_30.user + ) subq_31 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'user'] -- Aggregate Measures SELECT - subq_68.user + subq_38.user , SUM(buys) AS buys FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_64.visits) OVER ( + first_value(subq_34.visits) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_64.ds__day) OVER ( + , first_value(subq_34.ds__day) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_64.user) OVER ( + , first_value(subq_34.user) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_67.mf_internal_uuid AS mf_internal_uuid - , subq_67.buys AS buys + , subq_37.mf_internal_uuid AS mf_internal_uuid + , subq_37.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -87,7 +87,7 @@ FROM ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_64 + ) subq_34 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -98,23 +98,23 @@ FROM ( , 1 AS buys , UUID_STRING() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_67 + ) subq_37 ON ( - subq_64.user = subq_67.user + subq_34.user = subq_37.user ) AND ( - (subq_64.ds__day <= subq_67.ds__day) + (subq_34.ds__day <= subq_37.ds__day) ) - ) subq_68 + ) subq_38 GROUP BY - subq_68.user - ) subq_71 + subq_38.user + ) subq_41 ON - subq_61.user = subq_71.user + subq_31.user = subq_41.user GROUP BY - COALESCE(subq_61.user, subq_71.user) - ) subq_72 + COALESCE(subq_31.user, subq_41.user) + ) subq_42 ON - subq_57.user = subq_72.user -) subq_76 + subq_27.user = subq_42.user +) subq_46 WHERE user__visit_buy_conversion_rate > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_group_by_has_local_entity_prefix__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_group_by_has_local_entity_prefix__plan0.sql index b8e22ecd2c..b72141800b 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_group_by_has_local_entity_prefix__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_group_by_has_local_entity_prefix__plan0.sql @@ -1,106 +1,106 @@ -- Compute Metrics via Expressions SELECT - subq_27.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_26.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_25.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_24.user__listing__user__average_booking_value - , subq_24.listings + subq_15.user__listing__user__average_booking_value + , subq_15.listings FROM ( -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_23.user__listing__user__average_booking_value - , subq_23.listings + subq_14.user__listing__user__average_booking_value + , subq_14.listings FROM ( -- Join Standard Outputs SELECT - subq_11.user AS user - , subq_22.listing__user AS user__listing__user - , subq_22.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_11.listings AS listings + subq_2.user AS user + , subq_13.listing__user AS user__listing__user + , subq_13.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_10.user - , subq_10.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__extract_quarter - , subq_9.ds__extract_month - , subq_9.ds__extract_day - , subq_9.ds__extract_dow - , subq_9.ds__extract_doy - , subq_9.created_at__day - , subq_9.created_at__week - , subq_9.created_at__month - , subq_9.created_at__quarter - , subq_9.created_at__year - , subq_9.created_at__extract_year - , subq_9.created_at__extract_quarter - , subq_9.created_at__extract_month - , subq_9.created_at__extract_day - , subq_9.created_at__extract_dow - , subq_9.created_at__extract_doy - , subq_9.listing__ds__day - , subq_9.listing__ds__week - , subq_9.listing__ds__month - , subq_9.listing__ds__quarter - , subq_9.listing__ds__year - , subq_9.listing__ds__extract_year - , subq_9.listing__ds__extract_quarter - , subq_9.listing__ds__extract_month - , subq_9.listing__ds__extract_day - , subq_9.listing__ds__extract_dow - , subq_9.listing__ds__extract_doy - , subq_9.listing__created_at__day - , subq_9.listing__created_at__week - , subq_9.listing__created_at__month - , subq_9.listing__created_at__quarter - , subq_9.listing__created_at__year - , subq_9.listing__created_at__extract_year - , subq_9.listing__created_at__extract_quarter - , subq_9.listing__created_at__extract_month - , subq_9.listing__created_at__extract_day - , subq_9.listing__created_at__extract_dow - , subq_9.listing__created_at__extract_doy - , subq_9.ds__day AS metric_time__day - , subq_9.ds__week AS metric_time__week - , subq_9.ds__month AS metric_time__month - , subq_9.ds__quarter AS metric_time__quarter - , subq_9.ds__year AS metric_time__year - , subq_9.ds__extract_year AS metric_time__extract_year - , subq_9.ds__extract_quarter AS metric_time__extract_quarter - , subq_9.ds__extract_month AS metric_time__extract_month - , subq_9.ds__extract_day AS metric_time__extract_day - , subq_9.ds__extract_dow AS metric_time__extract_dow - , subq_9.ds__extract_doy AS metric_time__extract_doy - , subq_9.listing - , subq_9.user - , subq_9.listing__user - , subq_9.country_latest - , subq_9.is_lux_latest - , subq_9.capacity_latest - , subq_9.listing__country_latest - , subq_9.listing__is_lux_latest - , subq_9.listing__capacity_latest - , subq_9.listings - , subq_9.largest_listing - , subq_9.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -161,141 +161,141 @@ 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_9 - ) subq_10 - ) subq_11 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] SELECT - subq_21.listing__user - , subq_21.listing__user__average_booking_value + subq_12.listing__user + , subq_12.listing__user__average_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_20.listing__user - , subq_20.average_booking_value AS listing__user__average_booking_value + subq_11.listing__user + , subq_11.average_booking_value AS listing__user__average_booking_value FROM ( -- Aggregate Measures SELECT - subq_19.listing__user - , AVG(subq_19.average_booking_value) AS average_booking_value + subq_10.listing__user + , AVG(subq_10.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__user'] SELECT - subq_18.listing__user - , subq_18.average_booking_value + subq_9.listing__user + , subq_9.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_14.listing AS listing - , subq_17.user AS listing__user - , subq_14.average_booking_value AS average_booking_value + subq_5.listing AS listing + , subq_8.user AS listing__user + , subq_5.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing'] SELECT - subq_13.listing - , subq_13.average_booking_value + subq_4.listing + , subq_4.average_booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -388,84 +388,84 @@ 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_12 - ) subq_13 - ) subq_14 + ) subq_3 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'user'] SELECT - subq_16.listing - , subq_16.user + subq_7.listing + , subq_7.user FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.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 @@ -526,23 +526,23 @@ 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_15 - ) subq_16 - ) subq_17 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_5.listing = subq_8.listing + ) subq_9 + ) subq_10 GROUP BY - subq_19.listing__user - ) subq_20 - ) subq_21 - ) subq_22 + subq_10.listing__user + ) subq_11 + ) subq_12 + ) subq_13 ON - subq_11.user = subq_22.listing__user - ) subq_23 - ) subq_24 + subq_2.user = subq_13.listing__user + ) subq_14 + ) subq_15 WHERE user__listing__user__average_booking_value > 1 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_group_by_has_local_entity_prefix__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_group_by_has_local_entity_prefix__plan0_optimized.sql index f2d9e26580..8a2de81699 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_group_by_has_local_entity_prefix__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_group_by_has_local_entity_prefix__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_50.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_39.listings AS listings + subq_32.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_21.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_39 + ) subq_21 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__user'] @@ -35,8 +35,8 @@ FROM ( bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY listings_latest_src_28000.user_id - ) subq_50 + ) subq_32 ON - subq_39.user = subq_50.listing__user -) subq_52 + subq_21.user = subq_32.listing__user +) subq_34 WHERE user__listing__user__average_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_multi_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_multi_hop__plan0.sql index 0411633312..57cfc5f054 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_multi_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_multi_hop__plan0.sql @@ -1,76 +1,76 @@ -- Compute Metrics via Expressions SELECT - subq_40.third_hop_count + subq_22.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_39.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_21.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_38.third_hop_count + subq_20.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_37.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_37.third_hop_count + subq_19.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_19.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_36.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_36.third_hop_count + subq_18.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_18.third_hop_count FROM ( -- Join Standard Outputs SELECT - subq_20.customer_third_hop_id AS customer_third_hop_id - , subq_35.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id - , subq_35.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_20.third_hop_count AS third_hop_count + subq_2.customer_third_hop_id AS customer_third_hop_id + , subq_17.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_17.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_2.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_19.customer_third_hop_id - , subq_19.third_hop_count + subq_1.customer_third_hop_id + , subq_1.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - subq_18.third_hop_ds__day - , subq_18.third_hop_ds__week - , subq_18.third_hop_ds__month - , subq_18.third_hop_ds__quarter - , subq_18.third_hop_ds__year - , subq_18.third_hop_ds__extract_year - , subq_18.third_hop_ds__extract_quarter - , subq_18.third_hop_ds__extract_month - , subq_18.third_hop_ds__extract_day - , subq_18.third_hop_ds__extract_dow - , subq_18.third_hop_ds__extract_doy - , subq_18.customer_third_hop_id__third_hop_ds__day - , subq_18.customer_third_hop_id__third_hop_ds__week - , subq_18.customer_third_hop_id__third_hop_ds__month - , subq_18.customer_third_hop_id__third_hop_ds__quarter - , subq_18.customer_third_hop_id__third_hop_ds__year - , subq_18.customer_third_hop_id__third_hop_ds__extract_year - , subq_18.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_18.customer_third_hop_id__third_hop_ds__extract_month - , subq_18.customer_third_hop_id__third_hop_ds__extract_day - , subq_18.customer_third_hop_id__third_hop_ds__extract_dow - , subq_18.customer_third_hop_id__third_hop_ds__extract_doy - , subq_18.third_hop_ds__day AS metric_time__day - , subq_18.third_hop_ds__week AS metric_time__week - , subq_18.third_hop_ds__month AS metric_time__month - , subq_18.third_hop_ds__quarter AS metric_time__quarter - , subq_18.third_hop_ds__year AS metric_time__year - , subq_18.third_hop_ds__extract_year AS metric_time__extract_year - , subq_18.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_18.third_hop_ds__extract_month AS metric_time__extract_month - , subq_18.third_hop_ds__extract_day AS metric_time__extract_day - , subq_18.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_18.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_18.customer_third_hop_id - , subq_18.value - , subq_18.customer_third_hop_id__value - , subq_18.third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( -- Read Elements From Semantic Model 'third_hop_table' SELECT @@ -101,105 +101,105 @@ 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_18 - ) subq_19 - ) subq_20 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_34.account_id__customer_id__customer_third_hop_id - , subq_34.account_id__customer_id__customer_third_hop_id__txn_count + subq_16.account_id__customer_id__customer_third_hop_id + , subq_16.account_id__customer_id__customer_third_hop_id__txn_count FROM ( -- Compute Metrics via Expressions SELECT - subq_33.account_id__customer_id__customer_third_hop_id - , subq_33.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count + subq_15.account_id__customer_id__customer_third_hop_id + , subq_15.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count FROM ( -- Aggregate Measures SELECT - subq_32.account_id__customer_id__customer_third_hop_id - , SUM(subq_32.txn_count) AS txn_count + subq_14.account_id__customer_id__customer_third_hop_id + , SUM(subq_14.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] SELECT - subq_31.account_id__customer_id__customer_third_hop_id - , subq_31.txn_count + subq_13.account_id__customer_id__customer_third_hop_id + , subq_13.txn_count FROM ( -- Join Standard Outputs SELECT - subq_23.ds_partitioned__day AS ds_partitioned__day - , subq_30.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_23.account_id AS account_id - , subq_30.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id - , subq_23.txn_count AS txn_count + subq_5.ds_partitioned__day AS ds_partitioned__day + , subq_12.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_5.account_id AS account_id + , subq_12.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + , subq_5.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_22.ds_partitioned__day - , subq_22.account_id - , subq_22.txn_count + subq_4.ds_partitioned__day + , subq_4.account_id + , subq_4.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_21.ds_partitioned__day - , subq_21.ds_partitioned__week - , subq_21.ds_partitioned__month - , subq_21.ds_partitioned__quarter - , subq_21.ds_partitioned__year - , subq_21.ds_partitioned__extract_year - , subq_21.ds_partitioned__extract_quarter - , subq_21.ds_partitioned__extract_month - , subq_21.ds_partitioned__extract_day - , subq_21.ds_partitioned__extract_dow - , subq_21.ds_partitioned__extract_doy - , subq_21.ds__day - , subq_21.ds__week - , subq_21.ds__month - , subq_21.ds__quarter - , subq_21.ds__year - , subq_21.ds__extract_year - , subq_21.ds__extract_quarter - , subq_21.ds__extract_month - , subq_21.ds__extract_day - , subq_21.ds__extract_dow - , subq_21.ds__extract_doy - , subq_21.account_id__ds_partitioned__day - , subq_21.account_id__ds_partitioned__week - , subq_21.account_id__ds_partitioned__month - , subq_21.account_id__ds_partitioned__quarter - , subq_21.account_id__ds_partitioned__year - , subq_21.account_id__ds_partitioned__extract_year - , subq_21.account_id__ds_partitioned__extract_quarter - , subq_21.account_id__ds_partitioned__extract_month - , subq_21.account_id__ds_partitioned__extract_day - , subq_21.account_id__ds_partitioned__extract_dow - , subq_21.account_id__ds_partitioned__extract_doy - , subq_21.account_id__ds__day - , subq_21.account_id__ds__week - , subq_21.account_id__ds__month - , subq_21.account_id__ds__quarter - , subq_21.account_id__ds__year - , subq_21.account_id__ds__extract_year - , subq_21.account_id__ds__extract_quarter - , subq_21.account_id__ds__extract_month - , subq_21.account_id__ds__extract_day - , subq_21.account_id__ds__extract_dow - , subq_21.account_id__ds__extract_doy - , subq_21.ds__day AS metric_time__day - , subq_21.ds__week AS metric_time__week - , subq_21.ds__month AS metric_time__month - , subq_21.ds__quarter AS metric_time__quarter - , subq_21.ds__year AS metric_time__year - , subq_21.ds__extract_year AS metric_time__extract_year - , subq_21.ds__extract_quarter AS metric_time__extract_quarter - , subq_21.ds__extract_month AS metric_time__extract_month - , subq_21.ds__extract_day AS metric_time__extract_day - , subq_21.ds__extract_dow AS metric_time__extract_dow - , subq_21.ds__extract_doy AS metric_time__extract_doy - , subq_21.account_id - , subq_21.account_month - , subq_21.account_id__account_month - , subq_21.txn_count + 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.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.account_id__ds_partitioned__day + , subq_3.account_id__ds_partitioned__week + , subq_3.account_id__ds_partitioned__month + , subq_3.account_id__ds_partitioned__quarter + , subq_3.account_id__ds_partitioned__year + , subq_3.account_id__ds_partitioned__extract_year + , subq_3.account_id__ds_partitioned__extract_quarter + , subq_3.account_id__ds_partitioned__extract_month + , subq_3.account_id__ds_partitioned__extract_day + , subq_3.account_id__ds_partitioned__extract_dow + , subq_3.account_id__ds_partitioned__extract_doy + , subq_3.account_id__ds__day + , subq_3.account_id__ds__week + , subq_3.account_id__ds__month + , subq_3.account_id__ds__quarter + , subq_3.account_id__ds__year + , subq_3.account_id__ds__extract_year + , subq_3.account_id__ds__extract_quarter + , subq_3.account_id__ds__extract_month + , subq_3.account_id__ds__extract_day + , subq_3.account_id__ds__extract_dow + , subq_3.account_id__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_3.account_id + , subq_3.account_month + , subq_3.account_id__account_month + , subq_3.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -252,164 +252,164 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_3 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] SELECT - subq_29.ds_partitioned__day - , subq_29.account_id - , subq_29.customer_id__customer_third_hop_id + subq_11.ds_partitioned__day + , subq_11.account_id + , subq_11.customer_id__customer_third_hop_id FROM ( -- Join Standard Outputs SELECT - subq_25.ds_partitioned__day AS ds_partitioned__day - , subq_25.ds_partitioned__week AS ds_partitioned__week - , subq_25.ds_partitioned__month AS ds_partitioned__month - , subq_25.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_25.ds_partitioned__year AS ds_partitioned__year - , subq_25.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_25.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_25.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_25.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_25.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_25.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_25.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_25.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_25.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_25.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_25.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_25.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_25.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_25.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_25.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_25.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_25.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_25.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_25.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_25.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_25.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_25.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_25.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_25.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_25.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_25.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_25.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_25.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_25.metric_time__day AS metric_time__day - , subq_25.metric_time__week AS metric_time__week - , subq_25.metric_time__month AS metric_time__month - , subq_25.metric_time__quarter AS metric_time__quarter - , subq_25.metric_time__year AS metric_time__year - , subq_25.metric_time__extract_year AS metric_time__extract_year - , subq_25.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_25.metric_time__extract_month AS metric_time__extract_month - , subq_25.metric_time__extract_day AS metric_time__extract_day - , subq_25.metric_time__extract_dow AS metric_time__extract_dow - , subq_25.metric_time__extract_doy AS metric_time__extract_doy - , subq_28.acquired_ds__day AS customer_id__acquired_ds__day - , subq_28.acquired_ds__week AS customer_id__acquired_ds__week - , subq_28.acquired_ds__month AS customer_id__acquired_ds__month - , subq_28.acquired_ds__quarter AS customer_id__acquired_ds__quarter - , subq_28.acquired_ds__year AS customer_id__acquired_ds__year - , subq_28.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year - , subq_28.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter - , subq_28.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month - , subq_28.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day - , subq_28.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow - , subq_28.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy - , subq_28.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day - , subq_28.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week - , subq_28.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month - , subq_28.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter - , subq_28.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year - , subq_28.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year - , subq_28.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter - , subq_28.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month - , subq_28.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day - , subq_28.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow - , subq_28.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy - , subq_28.metric_time__day AS customer_id__metric_time__day - , subq_28.metric_time__week AS customer_id__metric_time__week - , subq_28.metric_time__month AS customer_id__metric_time__month - , subq_28.metric_time__quarter AS customer_id__metric_time__quarter - , subq_28.metric_time__year AS customer_id__metric_time__year - , subq_28.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_28.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_28.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_28.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_28.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_28.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_25.account_id AS account_id - , subq_25.customer_id AS customer_id - , subq_25.account_id__customer_id AS account_id__customer_id - , subq_25.bridge_account__account_id AS bridge_account__account_id - , subq_25.bridge_account__customer_id AS bridge_account__customer_id - , subq_28.customer_third_hop_id AS customer_id__customer_third_hop_id - , subq_28.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id - , subq_25.extra_dim AS extra_dim - , subq_25.account_id__extra_dim AS account_id__extra_dim - , subq_25.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_28.country AS customer_id__country - , subq_28.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country - , subq_25.account_customer_combos AS account_customer_combos + subq_7.ds_partitioned__day AS ds_partitioned__day + , subq_7.ds_partitioned__week AS ds_partitioned__week + , subq_7.ds_partitioned__month AS ds_partitioned__month + , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_7.ds_partitioned__year AS ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_7.metric_time__day AS metric_time__day + , subq_7.metric_time__week AS metric_time__week + , subq_7.metric_time__month AS metric_time__month + , subq_7.metric_time__quarter AS metric_time__quarter + , subq_7.metric_time__year AS metric_time__year + , subq_7.metric_time__extract_year AS metric_time__extract_year + , subq_7.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_7.metric_time__extract_month AS metric_time__extract_month + , subq_7.metric_time__extract_day AS metric_time__extract_day + , subq_7.metric_time__extract_dow AS metric_time__extract_dow + , subq_7.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.acquired_ds__day AS customer_id__acquired_ds__day + , subq_10.acquired_ds__week AS customer_id__acquired_ds__week + , subq_10.acquired_ds__month AS customer_id__acquired_ds__month + , subq_10.acquired_ds__quarter AS customer_id__acquired_ds__quarter + , subq_10.acquired_ds__year AS customer_id__acquired_ds__year + , subq_10.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year + , subq_10.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter + , subq_10.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month + , subq_10.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day + , subq_10.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow + , subq_10.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy + , subq_10.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day + , subq_10.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week + , subq_10.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month + , subq_10.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter + , subq_10.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year + , subq_10.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year + , subq_10.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter + , subq_10.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month + , subq_10.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day + , subq_10.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow + , subq_10.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy + , subq_10.metric_time__day AS customer_id__metric_time__day + , subq_10.metric_time__week AS customer_id__metric_time__week + , subq_10.metric_time__month AS customer_id__metric_time__month + , subq_10.metric_time__quarter AS customer_id__metric_time__quarter + , subq_10.metric_time__year AS customer_id__metric_time__year + , subq_10.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_10.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_10.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_10.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_10.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_10.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_7.account_id AS account_id + , subq_7.customer_id AS customer_id + , subq_7.account_id__customer_id AS account_id__customer_id + , subq_7.bridge_account__account_id AS bridge_account__account_id + , subq_7.bridge_account__customer_id AS bridge_account__customer_id + , subq_10.customer_third_hop_id AS customer_id__customer_third_hop_id + , subq_10.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id + , subq_7.extra_dim AS extra_dim + , subq_7.account_id__extra_dim AS account_id__extra_dim + , subq_7.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_10.country AS customer_id__country + , subq_10.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country + , subq_7.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.account_id__ds_partitioned__day - , subq_24.account_id__ds_partitioned__week - , subq_24.account_id__ds_partitioned__month - , subq_24.account_id__ds_partitioned__quarter - , subq_24.account_id__ds_partitioned__year - , subq_24.account_id__ds_partitioned__extract_year - , subq_24.account_id__ds_partitioned__extract_quarter - , subq_24.account_id__ds_partitioned__extract_month - , subq_24.account_id__ds_partitioned__extract_day - , subq_24.account_id__ds_partitioned__extract_dow - , subq_24.account_id__ds_partitioned__extract_doy - , subq_24.bridge_account__ds_partitioned__day - , subq_24.bridge_account__ds_partitioned__week - , subq_24.bridge_account__ds_partitioned__month - , subq_24.bridge_account__ds_partitioned__quarter - , subq_24.bridge_account__ds_partitioned__year - , subq_24.bridge_account__ds_partitioned__extract_year - , subq_24.bridge_account__ds_partitioned__extract_quarter - , subq_24.bridge_account__ds_partitioned__extract_month - , subq_24.bridge_account__ds_partitioned__extract_day - , subq_24.bridge_account__ds_partitioned__extract_dow - , subq_24.bridge_account__ds_partitioned__extract_doy - , subq_24.ds_partitioned__day AS metric_time__day - , subq_24.ds_partitioned__week AS metric_time__week - , subq_24.ds_partitioned__month AS metric_time__month - , subq_24.ds_partitioned__quarter AS metric_time__quarter - , subq_24.ds_partitioned__year AS metric_time__year - , subq_24.ds_partitioned__extract_year AS metric_time__extract_year - , subq_24.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_24.ds_partitioned__extract_month AS metric_time__extract_month - , subq_24.ds_partitioned__extract_day AS metric_time__extract_day - , subq_24.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_24.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_24.account_id - , subq_24.customer_id - , subq_24.account_id__customer_id - , subq_24.bridge_account__account_id - , subq_24.bridge_account__customer_id - , subq_24.extra_dim - , subq_24.account_id__extra_dim - , subq_24.bridge_account__extra_dim - , subq_24.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_6.account_id__ds_partitioned__week + , subq_6.account_id__ds_partitioned__month + , subq_6.account_id__ds_partitioned__quarter + , subq_6.account_id__ds_partitioned__year + , subq_6.account_id__ds_partitioned__extract_year + , subq_6.account_id__ds_partitioned__extract_quarter + , subq_6.account_id__ds_partitioned__extract_month + , subq_6.account_id__ds_partitioned__extract_day + , subq_6.account_id__ds_partitioned__extract_dow + , subq_6.account_id__ds_partitioned__extract_doy + , subq_6.bridge_account__ds_partitioned__day + , subq_6.bridge_account__ds_partitioned__week + , subq_6.bridge_account__ds_partitioned__month + , subq_6.bridge_account__ds_partitioned__quarter + , subq_6.bridge_account__ds_partitioned__year + , subq_6.bridge_account__ds_partitioned__extract_year + , subq_6.bridge_account__ds_partitioned__extract_quarter + , subq_6.bridge_account__ds_partitioned__extract_month + , subq_6.bridge_account__ds_partitioned__extract_day + , subq_6.bridge_account__ds_partitioned__extract_dow + , subq_6.bridge_account__ds_partitioned__extract_doy + , subq_6.ds_partitioned__day AS metric_time__day + , subq_6.ds_partitioned__week AS metric_time__week + , subq_6.ds_partitioned__month AS metric_time__month + , subq_6.ds_partitioned__quarter AS metric_time__quarter + , subq_6.ds_partitioned__year AS metric_time__year + , subq_6.ds_partitioned__extract_year AS metric_time__extract_year + , subq_6.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_6.ds_partitioned__extract_month AS metric_time__extract_month + , subq_6.ds_partitioned__extract_day AS metric_time__extract_day + , subq_6.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_6.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_6.account_id + , subq_6.customer_id + , subq_6.account_id__customer_id + , subq_6.bridge_account__account_id + , subq_6.bridge_account__customer_id + , subq_6.extra_dim + , subq_6.account_id__extra_dim + , subq_6.bridge_account__extra_dim + , subq_6.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -456,8 +456,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_24 - ) subq_25 + ) subq_6 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'country', @@ -513,112 +513,112 @@ FROM ( -- 'customer_third_hop_id__customer_id', -- ] SELECT - subq_27.acquired_ds__day - , subq_27.acquired_ds__week - , subq_27.acquired_ds__month - , subq_27.acquired_ds__quarter - , subq_27.acquired_ds__year - , subq_27.acquired_ds__extract_year - , subq_27.acquired_ds__extract_quarter - , subq_27.acquired_ds__extract_month - , subq_27.acquired_ds__extract_day - , subq_27.acquired_ds__extract_dow - , subq_27.acquired_ds__extract_doy - , subq_27.customer_id__acquired_ds__day - , subq_27.customer_id__acquired_ds__week - , subq_27.customer_id__acquired_ds__month - , subq_27.customer_id__acquired_ds__quarter - , subq_27.customer_id__acquired_ds__year - , subq_27.customer_id__acquired_ds__extract_year - , subq_27.customer_id__acquired_ds__extract_quarter - , subq_27.customer_id__acquired_ds__extract_month - , subq_27.customer_id__acquired_ds__extract_day - , subq_27.customer_id__acquired_ds__extract_dow - , subq_27.customer_id__acquired_ds__extract_doy - , subq_27.customer_third_hop_id__acquired_ds__day - , subq_27.customer_third_hop_id__acquired_ds__week - , subq_27.customer_third_hop_id__acquired_ds__month - , subq_27.customer_third_hop_id__acquired_ds__quarter - , subq_27.customer_third_hop_id__acquired_ds__year - , subq_27.customer_third_hop_id__acquired_ds__extract_year - , subq_27.customer_third_hop_id__acquired_ds__extract_quarter - , subq_27.customer_third_hop_id__acquired_ds__extract_month - , subq_27.customer_third_hop_id__acquired_ds__extract_day - , subq_27.customer_third_hop_id__acquired_ds__extract_dow - , subq_27.customer_third_hop_id__acquired_ds__extract_doy - , subq_27.metric_time__day - , subq_27.metric_time__week - , subq_27.metric_time__month - , subq_27.metric_time__quarter - , subq_27.metric_time__year - , subq_27.metric_time__extract_year - , subq_27.metric_time__extract_quarter - , subq_27.metric_time__extract_month - , subq_27.metric_time__extract_day - , subq_27.metric_time__extract_dow - , subq_27.metric_time__extract_doy - , subq_27.customer_id - , subq_27.customer_third_hop_id - , subq_27.customer_id__customer_third_hop_id - , subq_27.customer_third_hop_id__customer_id - , subq_27.country - , subq_27.customer_id__country - , subq_27.customer_third_hop_id__country + subq_9.acquired_ds__day + , subq_9.acquired_ds__week + , subq_9.acquired_ds__month + , subq_9.acquired_ds__quarter + , subq_9.acquired_ds__year + , subq_9.acquired_ds__extract_year + , subq_9.acquired_ds__extract_quarter + , subq_9.acquired_ds__extract_month + , subq_9.acquired_ds__extract_day + , subq_9.acquired_ds__extract_dow + , subq_9.acquired_ds__extract_doy + , subq_9.customer_id__acquired_ds__day + , subq_9.customer_id__acquired_ds__week + , subq_9.customer_id__acquired_ds__month + , subq_9.customer_id__acquired_ds__quarter + , subq_9.customer_id__acquired_ds__year + , subq_9.customer_id__acquired_ds__extract_year + , subq_9.customer_id__acquired_ds__extract_quarter + , subq_9.customer_id__acquired_ds__extract_month + , subq_9.customer_id__acquired_ds__extract_day + , subq_9.customer_id__acquired_ds__extract_dow + , subq_9.customer_id__acquired_ds__extract_doy + , subq_9.customer_third_hop_id__acquired_ds__day + , subq_9.customer_third_hop_id__acquired_ds__week + , subq_9.customer_third_hop_id__acquired_ds__month + , subq_9.customer_third_hop_id__acquired_ds__quarter + , subq_9.customer_third_hop_id__acquired_ds__year + , subq_9.customer_third_hop_id__acquired_ds__extract_year + , subq_9.customer_third_hop_id__acquired_ds__extract_quarter + , subq_9.customer_third_hop_id__acquired_ds__extract_month + , subq_9.customer_third_hop_id__acquired_ds__extract_day + , subq_9.customer_third_hop_id__acquired_ds__extract_dow + , subq_9.customer_third_hop_id__acquired_ds__extract_doy + , subq_9.metric_time__day + , subq_9.metric_time__week + , subq_9.metric_time__month + , subq_9.metric_time__quarter + , subq_9.metric_time__year + , subq_9.metric_time__extract_year + , subq_9.metric_time__extract_quarter + , subq_9.metric_time__extract_month + , subq_9.metric_time__extract_day + , subq_9.metric_time__extract_dow + , subq_9.metric_time__extract_doy + , subq_9.customer_id + , subq_9.customer_third_hop_id + , subq_9.customer_id__customer_third_hop_id + , subq_9.customer_third_hop_id__customer_id + , subq_9.country + , subq_9.customer_id__country + , subq_9.customer_third_hop_id__country FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - subq_26.acquired_ds__day - , subq_26.acquired_ds__week - , subq_26.acquired_ds__month - , subq_26.acquired_ds__quarter - , subq_26.acquired_ds__year - , subq_26.acquired_ds__extract_year - , subq_26.acquired_ds__extract_quarter - , subq_26.acquired_ds__extract_month - , subq_26.acquired_ds__extract_day - , subq_26.acquired_ds__extract_dow - , subq_26.acquired_ds__extract_doy - , subq_26.customer_id__acquired_ds__day - , subq_26.customer_id__acquired_ds__week - , subq_26.customer_id__acquired_ds__month - , subq_26.customer_id__acquired_ds__quarter - , subq_26.customer_id__acquired_ds__year - , subq_26.customer_id__acquired_ds__extract_year - , subq_26.customer_id__acquired_ds__extract_quarter - , subq_26.customer_id__acquired_ds__extract_month - , subq_26.customer_id__acquired_ds__extract_day - , subq_26.customer_id__acquired_ds__extract_dow - , subq_26.customer_id__acquired_ds__extract_doy - , subq_26.customer_third_hop_id__acquired_ds__day - , subq_26.customer_third_hop_id__acquired_ds__week - , subq_26.customer_third_hop_id__acquired_ds__month - , subq_26.customer_third_hop_id__acquired_ds__quarter - , subq_26.customer_third_hop_id__acquired_ds__year - , subq_26.customer_third_hop_id__acquired_ds__extract_year - , subq_26.customer_third_hop_id__acquired_ds__extract_quarter - , subq_26.customer_third_hop_id__acquired_ds__extract_month - , subq_26.customer_third_hop_id__acquired_ds__extract_day - , subq_26.customer_third_hop_id__acquired_ds__extract_dow - , subq_26.customer_third_hop_id__acquired_ds__extract_doy - , subq_26.acquired_ds__day AS metric_time__day - , subq_26.acquired_ds__week AS metric_time__week - , subq_26.acquired_ds__month AS metric_time__month - , subq_26.acquired_ds__quarter AS metric_time__quarter - , subq_26.acquired_ds__year AS metric_time__year - , subq_26.acquired_ds__extract_year AS metric_time__extract_year - , subq_26.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_26.acquired_ds__extract_month AS metric_time__extract_month - , subq_26.acquired_ds__extract_day AS metric_time__extract_day - , subq_26.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_26.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_26.customer_id - , subq_26.customer_third_hop_id - , subq_26.customer_id__customer_third_hop_id - , subq_26.customer_third_hop_id__customer_id - , subq_26.country - , subq_26.customer_id__country - , subq_26.customer_third_hop_id__country - , subq_26.customers_with_other_data + subq_8.acquired_ds__day + , subq_8.acquired_ds__week + , subq_8.acquired_ds__month + , subq_8.acquired_ds__quarter + , subq_8.acquired_ds__year + , subq_8.acquired_ds__extract_year + , subq_8.acquired_ds__extract_quarter + , subq_8.acquired_ds__extract_month + , subq_8.acquired_ds__extract_day + , subq_8.acquired_ds__extract_dow + , subq_8.acquired_ds__extract_doy + , subq_8.customer_id__acquired_ds__day + , subq_8.customer_id__acquired_ds__week + , subq_8.customer_id__acquired_ds__month + , subq_8.customer_id__acquired_ds__quarter + , subq_8.customer_id__acquired_ds__year + , subq_8.customer_id__acquired_ds__extract_year + , subq_8.customer_id__acquired_ds__extract_quarter + , subq_8.customer_id__acquired_ds__extract_month + , subq_8.customer_id__acquired_ds__extract_day + , subq_8.customer_id__acquired_ds__extract_dow + , subq_8.customer_id__acquired_ds__extract_doy + , subq_8.customer_third_hop_id__acquired_ds__day + , subq_8.customer_third_hop_id__acquired_ds__week + , subq_8.customer_third_hop_id__acquired_ds__month + , subq_8.customer_third_hop_id__acquired_ds__quarter + , subq_8.customer_third_hop_id__acquired_ds__year + , subq_8.customer_third_hop_id__acquired_ds__extract_year + , subq_8.customer_third_hop_id__acquired_ds__extract_quarter + , subq_8.customer_third_hop_id__acquired_ds__extract_month + , subq_8.customer_third_hop_id__acquired_ds__extract_day + , subq_8.customer_third_hop_id__acquired_ds__extract_dow + , subq_8.customer_third_hop_id__acquired_ds__extract_doy + , subq_8.acquired_ds__day AS metric_time__day + , subq_8.acquired_ds__week AS metric_time__week + , subq_8.acquired_ds__month AS metric_time__month + , subq_8.acquired_ds__quarter AS metric_time__quarter + , subq_8.acquired_ds__year AS metric_time__year + , subq_8.acquired_ds__extract_year AS metric_time__extract_year + , subq_8.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_8.acquired_ds__extract_month AS metric_time__extract_month + , subq_8.acquired_ds__extract_day AS metric_time__extract_day + , subq_8.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_8.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_8.customer_id + , subq_8.customer_third_hop_id + , subq_8.customer_id__customer_third_hop_id + , subq_8.customer_third_hop_id__customer_id + , subq_8.country + , subq_8.customer_id__country + , subq_8.customer_third_hop_id__country + , subq_8.customers_with_other_data FROM ( -- Read Elements From Semantic Model 'customer_other_data' SELECT @@ -664,31 +664,31 @@ 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_26 - ) subq_27 - ) subq_28 + ) subq_8 + ) subq_9 + ) subq_10 ON - subq_25.customer_id = subq_28.customer_id - ) subq_29 - ) subq_30 + subq_7.customer_id = subq_10.customer_id + ) subq_11 + ) subq_12 ON ( - subq_23.account_id = subq_30.account_id + subq_5.account_id = subq_12.account_id ) AND ( - subq_23.ds_partitioned__day = subq_30.ds_partitioned__day + subq_5.ds_partitioned__day = subq_12.ds_partitioned__day ) - ) subq_31 - ) subq_32 + ) subq_13 + ) subq_14 GROUP BY - subq_32.account_id__customer_id__customer_third_hop_id - ) subq_33 - ) subq_34 - ) subq_35 + subq_14.account_id__customer_id__customer_third_hop_id + ) subq_15 + ) subq_16 + ) subq_17 ON - subq_20.customer_third_hop_id = subq_35.account_id__customer_id__customer_third_hop_id - ) subq_36 - ) subq_37 + subq_2.customer_third_hop_id = subq_17.account_id__customer_id__customer_third_hop_id + ) subq_18 + ) subq_19 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 - ) subq_38 - ) subq_39 -) subq_40 + ) subq_20 + ) subq_21 +) subq_22 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_multi_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_multi_hop__plan0_optimized.sql index bf66de5356..97117da92a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_multi_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_multi_hop__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_76.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + subq_40.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count , 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 ( @@ -18,7 +18,7 @@ FROM ( -- Compute Metrics via Expressions -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_71.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + subq_35.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id , SUM(account_month_txns_src_22000.txn_count) AS account_id__customer_id__customer_third_hop_id__txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -33,17 +33,17 @@ FROM ( ***************************.customer_other_data customer_other_data_src_22000 ON bridge_table_src_22000.customer_id = customer_other_data_src_22000.customer_id - ) subq_71 + ) subq_35 ON ( - account_month_txns_src_22000.account_id = subq_71.account_id + account_month_txns_src_22000.account_id = subq_35.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_71.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_35.ds_partitioned__day ) GROUP BY - subq_71.customer_id__customer_third_hop_id - ) subq_76 + subq_35.customer_id__customer_third_hop_id + ) subq_40 ON - third_hop_table_src_22000.customer_third_hop_id = subq_76.account_id__customer_id__customer_third_hop_id -) subq_78 + third_hop_table_src_22000.customer_third_hop_id = subq_40.account_id__customer_id__customer_third_hop_id +) subq_42 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_single_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_single_hop__plan0.sql index fb72540d6e..4f89a5e4c9 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_single_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_single_hop__plan0.sql @@ -1,76 +1,76 @@ -- Compute Metrics via Expressions SELECT - subq_25.third_hop_count + subq_16.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_24.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_15.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_23.third_hop_count + subq_14.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_22.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_22.third_hop_count + subq_13.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_13.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_21.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_21.third_hop_count + subq_12.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_12.third_hop_count FROM ( -- Join Standard Outputs SELECT - 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 + subq_2.customer_third_hop_id AS customer_third_hop_id + , subq_11.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_11.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_2.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_10.customer_third_hop_id - , subq_10.third_hop_count + subq_1.customer_third_hop_id + , subq_1.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - 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 + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.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_9 - ) subq_10 - ) subq_11 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_19.customer_id__customer_third_hop_id - , subq_19.customer_id__customer_third_hop_id__paraguayan_customers + subq_10.customer_id__customer_third_hop_id + , subq_10.customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Compute Metrics via Expressions SELECT - subq_18.customer_id__customer_third_hop_id - , subq_18.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_9.customer_id__customer_third_hop_id + , subq_9.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Aggregate Measures SELECT - subq_17.customer_id__customer_third_hop_id - , SUM(subq_17.customers_with_other_data) AS customers_with_other_data + subq_8.customer_id__customer_third_hop_id + , SUM(subq_8.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_16.customer_id__customer_third_hop_id - , subq_16.customers_with_other_data + subq_7.customer_id__customer_third_hop_id + , subq_7.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_15.customer_id__customer_third_hop_id - , subq_15.customer_id__country - , subq_15.customers_with_other_data + subq_6.customer_id__customer_third_hop_id + , subq_6.customer_id__country + , subq_6.customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT - subq_14.customer_id__customer_third_hop_id - , subq_14.customer_id__country - , subq_14.customers_with_other_data + subq_5.customer_id__customer_third_hop_id + , subq_5.customer_id__country + , subq_5.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - 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 + subq_4.acquired_ds__day + , subq_4.acquired_ds__week + , subq_4.acquired_ds__month + , subq_4.acquired_ds__quarter + , subq_4.acquired_ds__year + , subq_4.acquired_ds__extract_year + , subq_4.acquired_ds__extract_quarter + , subq_4.acquired_ds__extract_month + , subq_4.acquired_ds__extract_day + , subq_4.acquired_ds__extract_dow + , subq_4.acquired_ds__extract_doy + , subq_4.customer_id__acquired_ds__day + , subq_4.customer_id__acquired_ds__week + , subq_4.customer_id__acquired_ds__month + , subq_4.customer_id__acquired_ds__quarter + , subq_4.customer_id__acquired_ds__year + , subq_4.customer_id__acquired_ds__extract_year + , subq_4.customer_id__acquired_ds__extract_quarter + , subq_4.customer_id__acquired_ds__extract_month + , subq_4.customer_id__acquired_ds__extract_day + , subq_4.customer_id__acquired_ds__extract_dow + , subq_4.customer_id__acquired_ds__extract_doy + , subq_4.customer_third_hop_id__acquired_ds__day + , subq_4.customer_third_hop_id__acquired_ds__week + , subq_4.customer_third_hop_id__acquired_ds__month + , subq_4.customer_third_hop_id__acquired_ds__quarter + , subq_4.customer_third_hop_id__acquired_ds__year + , subq_4.customer_third_hop_id__acquired_ds__extract_year + , subq_4.customer_third_hop_id__acquired_ds__extract_quarter + , subq_4.customer_third_hop_id__acquired_ds__extract_month + , subq_4.customer_third_hop_id__acquired_ds__extract_day + , subq_4.customer_third_hop_id__acquired_ds__extract_dow + , subq_4.customer_third_hop_id__acquired_ds__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.customer_id + , subq_4.customer_third_hop_id + , subq_4.customer_id__customer_third_hop_id + , subq_4.customer_third_hop_id__customer_id + , subq_4.country + , subq_4.customer_id__country + , subq_4.customer_third_hop_id__country + , subq_4.customers_with_other_data FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - 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 + subq_3.acquired_ds__day + , subq_3.acquired_ds__week + , subq_3.acquired_ds__month + , subq_3.acquired_ds__quarter + , subq_3.acquired_ds__year + , subq_3.acquired_ds__extract_year + , subq_3.acquired_ds__extract_quarter + , subq_3.acquired_ds__extract_month + , subq_3.acquired_ds__extract_day + , subq_3.acquired_ds__extract_dow + , subq_3.acquired_ds__extract_doy + , subq_3.customer_id__acquired_ds__day + , subq_3.customer_id__acquired_ds__week + , subq_3.customer_id__acquired_ds__month + , subq_3.customer_id__acquired_ds__quarter + , subq_3.customer_id__acquired_ds__year + , subq_3.customer_id__acquired_ds__extract_year + , subq_3.customer_id__acquired_ds__extract_quarter + , subq_3.customer_id__acquired_ds__extract_month + , subq_3.customer_id__acquired_ds__extract_day + , subq_3.customer_id__acquired_ds__extract_dow + , subq_3.customer_id__acquired_ds__extract_doy + , subq_3.customer_third_hop_id__acquired_ds__day + , subq_3.customer_third_hop_id__acquired_ds__week + , subq_3.customer_third_hop_id__acquired_ds__month + , subq_3.customer_third_hop_id__acquired_ds__quarter + , subq_3.customer_third_hop_id__acquired_ds__year + , subq_3.customer_third_hop_id__acquired_ds__extract_year + , subq_3.customer_third_hop_id__acquired_ds__extract_quarter + , subq_3.customer_third_hop_id__acquired_ds__extract_month + , subq_3.customer_third_hop_id__acquired_ds__extract_day + , subq_3.customer_third_hop_id__acquired_ds__extract_dow + , subq_3.customer_third_hop_id__acquired_ds__extract_doy + , subq_3.acquired_ds__day AS metric_time__day + , subq_3.acquired_ds__week AS metric_time__week + , subq_3.acquired_ds__month AS metric_time__month + , subq_3.acquired_ds__quarter AS metric_time__quarter + , subq_3.acquired_ds__year AS metric_time__year + , subq_3.acquired_ds__extract_year AS metric_time__extract_year + , subq_3.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_3.acquired_ds__extract_month AS metric_time__extract_month + , subq_3.acquired_ds__extract_day AS metric_time__extract_day + , subq_3.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_3.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_3.customer_id + , subq_3.customer_third_hop_id + , subq_3.customer_id__customer_third_hop_id + , subq_3.customer_third_hop_id__customer_id + , subq_3.country + , subq_3.customer_id__country + , subq_3.customer_third_hop_id__country + , subq_3.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_12 - ) subq_13 + ) subq_3 + ) subq_4 WHERE customer_id__country = 'paraguay' - ) subq_14 - ) subq_15 + ) subq_5 + ) subq_6 WHERE customer_id__country = 'paraguay' - ) subq_16 - ) subq_17 + ) subq_7 + ) subq_8 GROUP BY - subq_17.customer_id__customer_third_hop_id - ) subq_18 - ) subq_19 - ) subq_20 + subq_8.customer_id__customer_third_hop_id + ) subq_9 + ) subq_10 + ) subq_11 ON - subq_11.customer_third_hop_id = subq_20.customer_id__customer_third_hop_id - ) subq_21 - ) subq_22 + subq_2.customer_third_hop_id = subq_11.customer_id__customer_third_hop_id + ) subq_12 + ) subq_13 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_23 - ) subq_24 -) subq_25 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_single_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_single_hop__plan0_optimized.sql index 0fd2bf1820..b73c99c9a9 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_single_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/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_46.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_28.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_39 + ) subq_21 WHERE customer_id__country = 'paraguay' - ) subq_41 + ) subq_23 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_46 + ) subq_28 ON - third_hop_table_src_22000.customer_third_hop_id = subq_46.customer_id__customer_third_hop_id -) subq_48 + third_hop_table_src_22000.customer_third_hop_id = subq_28.customer_id__customer_third_hop_id +) subq_30 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_filtered_by_itself__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_filtered_by_itself__plan0.sql index f4bbf1d2bf..f96226cbe1 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_filtered_by_itself__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_filtered_by_itself__plan0.sql @@ -1,136 +1,136 @@ -- Compute Metrics via Expressions SELECT - subq_17.bookers + subq_13.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_16.bookers) AS bookers + COUNT(DISTINCT subq_12.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_15.bookers + subq_11.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_14.listing__bookers - , subq_14.bookers + subq_10.listing__bookers + , subq_10.bookers FROM ( -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_13.listing__bookers - , subq_13.bookers + subq_9.listing__bookers + , subq_9.bookers FROM ( -- Join Standard Outputs SELECT - subq_6.listing AS listing - , subq_12.listing__bookers AS listing__bookers - , subq_6.bookers AS bookers + subq_2.listing AS listing + , subq_8.listing__bookers AS listing__bookers + , subq_2.bookers AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_5.listing - , subq_5.bookers + subq_1.listing + , subq_1.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -223,130 +223,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookers'] SELECT - subq_11.listing - , subq_11.listing__bookers + subq_7.listing + , subq_7.listing__bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookers AS listing__bookers + subq_6.listing + , subq_6.bookers AS listing__bookers FROM ( -- Aggregate Measures SELECT - subq_9.listing - , COUNT(DISTINCT subq_9.bookers) AS bookers + subq_5.listing + , COUNT(DISTINCT subq_5.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_8.listing - , subq_8.bookers + subq_4.listing + , subq_4.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -439,19 +439,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.listing - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookers > 1.00 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_filtered_by_itself__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_filtered_by_itself__plan0_optimized.sql index e5c7db19a1..fc6f75f09e 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_filtered_by_itself__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_filtered_by_itself__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_30.listing__bookers AS listing__bookers - , subq_24.bookers AS bookers + subq_22.listing__bookers AS listing__bookers + , subq_16.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookers > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_metric_in_where_filter__plan0.sql index e42b014233..5123357f47 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_metric_in_where_filter__plan0.sql @@ -1,112 +1,112 @@ -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day - , subq_17.listings AS active_listings + subq_13.metric_time__day + , subq_13.listings AS active_listings FROM ( -- Aggregate Measures SELECT - subq_16.metric_time__day - , SUM(subq_16.listings) AS listings + subq_12.metric_time__day + , SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day'] SELECT - subq_15.metric_time__day - , subq_15.listings + subq_11.metric_time__day + , subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.metric_time__day - , subq_14.listing__bookings - , subq_14.listings + subq_10.metric_time__day + , subq_10.listing__bookings + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_13.metric_time__day - , subq_13.listing__bookings - , subq_13.listings + subq_9.metric_time__day + , subq_9.listing__bookings + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.metric_time__day AS metric_time__day - , subq_6.listing AS listing - , subq_12.listing__bookings AS listing__bookings - , subq_6.listings AS listings + subq_2.metric_time__day AS metric_time__day + , subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] SELECT - subq_5.metric_time__day - , subq_5.listing - , subq_5.listings + subq_1.metric_time__day + , subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -167,130 +167,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_11.listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing - , SUM(subq_9.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_8.listing - , subq_8.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -383,21 +383,21 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.listing - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookings > 2 - ) subq_15 - ) subq_16 + ) subq_11 + ) subq_12 GROUP BY - subq_16.metric_time__day -) subq_17 + subq_12.metric_time__day +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_metric_in_where_filter__plan0_optimized.sql index a43cba6c94..21fd1f7db3 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_metric_in_where_filter__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_24.metric_time__day AS metric_time__day - , subq_30.listing__bookings AS listing__bookings - , subq_24.listings AS listings + subq_16.metric_time__day AS metric_time__day + , subq_22.listing__bookings AS listing__bookings + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -21,7 +21,7 @@ FROM ( , listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -37,13 +37,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_27 + ) subq_19 GROUP BY listing - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookings > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_cumulative_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_cumulative_metric_in_where_filter__plan0.sql index 9a417bb280..96442754af 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_cumulative_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_cumulative_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_17.listings + subq_13.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_16.listings) AS listings + SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_15.listings + subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.user__revenue_all_time - , subq_14.listings + subq_10.user__revenue_all_time + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_13.user__revenue_all_time - , subq_13.listings + subq_9.user__revenue_all_time + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.user AS user - , subq_12.user__revenue_all_time AS user__revenue_all_time - , subq_6.listings AS listings + subq_2.user AS user + , subq_8.user__revenue_all_time AS user__revenue_all_time + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_5.user - , subq_5.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,68 +160,68 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user', 'user__revenue_all_time'] SELECT - subq_11.user - , subq_11.user__revenue_all_time + subq_7.user + , subq_7.user__revenue_all_time FROM ( -- Compute Metrics via Expressions SELECT - subq_10.user - , subq_10.txn_revenue AS user__revenue_all_time + subq_6.user + , subq_6.txn_revenue AS user__revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_9.user - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_5.user + , SUM(subq_5.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'user'] SELECT - subq_8.user - , subq_8.txn_revenue + subq_4.user + , subq_4.txn_revenue FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.revenue_instance__ds__day - , subq_7.revenue_instance__ds__week - , subq_7.revenue_instance__ds__month - , subq_7.revenue_instance__ds__quarter - , subq_7.revenue_instance__ds__year - , subq_7.revenue_instance__ds__extract_year - , subq_7.revenue_instance__ds__extract_quarter - , subq_7.revenue_instance__ds__extract_month - , subq_7.revenue_instance__ds__extract_day - , subq_7.revenue_instance__ds__extract_dow - , subq_7.revenue_instance__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.revenue_instance__user - , subq_7.txn_revenue + 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.revenue_instance__ds__day + , subq_3.revenue_instance__ds__week + , subq_3.revenue_instance__ds__month + , subq_3.revenue_instance__ds__quarter + , subq_3.revenue_instance__ds__year + , subq_3.revenue_instance__ds__extract_year + , subq_3.revenue_instance__ds__extract_quarter + , subq_3.revenue_instance__ds__extract_month + , subq_3.revenue_instance__ds__extract_day + , subq_3.revenue_instance__ds__extract_dow + , subq_3.revenue_instance__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_3.user + , subq_3.revenue_instance__user + , subq_3.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -251,19 +251,19 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.user - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.user + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.user = subq_12.user - ) subq_13 - ) subq_14 + subq_2.user = subq_8.user + ) subq_9 + ) subq_10 WHERE user__revenue_all_time > 1 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql index 4f006f13ed..2b782589e8 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_30.user__revenue_all_time AS user__revenue_all_time - , subq_24.listings AS listings + subq_22.user__revenue_all_time AS user__revenue_all_time + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_revenue revenue_src_28000 GROUP BY user_id - ) subq_30 + ) subq_22 ON - subq_24.user = subq_30.user -) subq_32 + subq_16.user = subq_22.user +) subq_24 WHERE user__revenue_all_time > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_derived_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_derived_metric_in_where_filter__plan0.sql index d319d96b6c..ab98e985f0 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_derived_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_derived_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_31.listings + subq_20.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_30.listings) AS listings + SUM(subq_19.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_29.listings + subq_18.listings FROM ( -- Constrain Output with WHERE SELECT - subq_28.listing__views_times_booking_value - , subq_28.listings + subq_17.listing__views_times_booking_value + , subq_17.listings FROM ( -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_27.listing__views_times_booking_value - , subq_27.listings + subq_16.listing__views_times_booking_value + , subq_16.listings FROM ( -- Join Standard Outputs SELECT - subq_13.listing AS listing - , subq_26.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_13.listings AS listings + subq_2.listing AS listing + , subq_15.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_12.listing - , subq_12.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,141 +160,141 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] SELECT - subq_25.listing - , subq_25.listing__views_times_booking_value + subq_14.listing + , subq_14.listing__views_times_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_24.listing + subq_13.listing , booking_value * views AS listing__views_times_booking_value FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.listing, subq_23.listing) AS listing - , MAX(subq_18.booking_value) AS booking_value - , MAX(subq_23.views) AS views + COALESCE(subq_7.listing, subq_12.listing) AS listing + , MAX(subq_7.booking_value) AS booking_value + , MAX(subq_12.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_17.listing - , subq_17.booking_value + subq_6.listing + , subq_6.booking_value FROM ( -- Aggregate Measures SELECT - subq_16.listing - , SUM(subq_16.booking_value) AS booking_value + subq_5.listing + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'listing'] SELECT - subq_15.listing - , subq_15.booking_value + subq_4.listing + , subq_4.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_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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -387,91 +387,91 @@ 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_3 + ) subq_4 + ) subq_5 GROUP BY - subq_16.listing - ) subq_17 - ) subq_18 + subq_5.listing + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.listing - , subq_22.views + subq_11.listing + , subq_11.views FROM ( -- Aggregate Measures SELECT - subq_21.listing - , SUM(subq_21.views) AS views + subq_10.listing + , SUM(subq_10.views) AS views FROM ( -- Pass Only Elements: ['views', 'listing'] SELECT - subq_20.listing - , subq_20.views + subq_9.listing + , subq_9.views FROM ( -- Metric Time Dimension 'ds' 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.view__ds__day - , subq_19.view__ds__week - , subq_19.view__ds__month - , subq_19.view__ds__quarter - , subq_19.view__ds__year - , subq_19.view__ds__extract_year - , subq_19.view__ds__extract_quarter - , subq_19.view__ds__extract_month - , subq_19.view__ds__extract_day - , subq_19.view__ds__extract_dow - , subq_19.view__ds__extract_doy - , subq_19.view__ds_partitioned__day - , subq_19.view__ds_partitioned__week - , subq_19.view__ds_partitioned__month - , subq_19.view__ds_partitioned__quarter - , subq_19.view__ds_partitioned__year - , subq_19.view__ds_partitioned__extract_year - , subq_19.view__ds_partitioned__extract_quarter - , subq_19.view__ds_partitioned__extract_month - , subq_19.view__ds_partitioned__extract_day - , subq_19.view__ds_partitioned__extract_dow - , subq_19.view__ds_partitioned__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.user - , subq_19.view__listing - , subq_19.view__user - , subq_19.views + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.view__ds__day + , subq_8.view__ds__week + , subq_8.view__ds__month + , subq_8.view__ds__quarter + , subq_8.view__ds__year + , subq_8.view__ds__extract_year + , subq_8.view__ds__extract_quarter + , subq_8.view__ds__extract_month + , subq_8.view__ds__extract_day + , subq_8.view__ds__extract_dow + , subq_8.view__ds__extract_doy + , subq_8.view__ds_partitioned__day + , subq_8.view__ds_partitioned__week + , subq_8.view__ds_partitioned__month + , subq_8.view__ds_partitioned__quarter + , subq_8.view__ds_partitioned__year + , subq_8.view__ds_partitioned__extract_year + , subq_8.view__ds_partitioned__extract_quarter + , subq_8.view__ds_partitioned__extract_month + , subq_8.view__ds_partitioned__extract_day + , subq_8.view__ds_partitioned__extract_dow + , subq_8.view__ds_partitioned__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.user + , subq_8.view__listing + , subq_8.view__user + , subq_8.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT @@ -525,25 +525,25 @@ FROM ( , views_source_src_28000.listing_id AS view__listing , views_source_src_28000.user_id AS view__user FROM ***************************.fct_views views_source_src_28000 - ) subq_19 - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_21.listing - ) subq_22 - ) subq_23 + subq_10.listing + ) subq_11 + ) subq_12 ON - subq_18.listing = subq_23.listing + subq_7.listing = subq_12.listing GROUP BY - COALESCE(subq_18.listing, subq_23.listing) - ) subq_24 - ) subq_25 - ) subq_26 + COALESCE(subq_7.listing, subq_12.listing) + ) subq_13 + ) subq_14 + ) subq_15 ON - subq_13.listing = subq_26.listing - ) subq_27 - ) subq_28 + subq_2.listing = subq_15.listing + ) subq_16 + ) subq_17 WHERE listing__views_times_booking_value > 1 - ) subq_29 - ) subq_30 -) subq_31 + ) subq_18 + ) subq_19 +) subq_20 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql index f8024b63f1..e5f6bf61fb 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_58.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_45.listings AS listings + subq_36.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_23.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_45 + ) subq_23 LEFT OUTER JOIN ( -- Compute Metrics via Expressions -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] @@ -28,9 +28,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_50.listing, subq_55.listing) AS listing - , MAX(subq_50.booking_value) AS booking_value - , MAX(subq_55.views) AS views + COALESCE(subq_28.listing, subq_33.listing) AS listing + , MAX(subq_28.booking_value) AS booking_value + , MAX(subq_33.views) AS views FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -43,7 +43,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_50 + ) subq_28 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -58,17 +58,17 @@ FROM ( listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_53 + ) subq_31 GROUP BY listing - ) subq_55 + ) subq_33 ON - subq_50.listing = subq_55.listing + subq_28.listing = subq_33.listing GROUP BY - COALESCE(subq_50.listing, subq_55.listing) - ) subq_56 - ) subq_58 + COALESCE(subq_28.listing, subq_33.listing) + ) subq_34 + ) subq_36 ON - subq_45.listing = subq_58.listing -) subq_60 + subq_23.listing = subq_36.listing +) subq_38 WHERE listing__views_times_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_multiple_metrics_in_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_multiple_metrics_in_filter__plan0.sql index 2b552053fc..5c032234bd 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_multiple_metrics_in_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_multiple_metrics_in_filter__plan0.sql @@ -1,108 +1,108 @@ -- Compute Metrics via Expressions SELECT - subq_27.listings + subq_19.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_26.listings) AS listings + SUM(subq_18.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_25.listings + subq_17.listings FROM ( -- Constrain Output with WHERE SELECT - subq_24.listing__bookings - , subq_24.listing__bookers - , subq_24.listings + subq_16.listing__bookings + , subq_16.listing__bookers + , subq_16.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_23.listing__bookings - , subq_23.listing__bookers - , subq_23.listings + subq_15.listing__bookings + , subq_15.listing__bookers + , subq_15.listings FROM ( -- Join Standard Outputs SELECT - subq_10.listing AS listing - , subq_16.listing__bookings AS listing__bookings - , subq_22.listing__bookers AS listing__bookers - , subq_10.listings AS listings + subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_14.listing__bookers AS listing__bookers + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing', 'listing'] SELECT - subq_9.listing - , subq_9.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' 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.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , 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.listings - , subq_8.largest_listing - , subq_8.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -163,130 +163,130 @@ 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_8 - ) subq_9 - ) subq_10 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_15.listing - , subq_15.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_13.listing - , SUM(subq_13.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_12.listing - , subq_12.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.paid_at__day - , subq_11.paid_at__week - , subq_11.paid_at__month - , subq_11.paid_at__quarter - , subq_11.paid_at__year - , subq_11.paid_at__extract_year - , subq_11.paid_at__extract_quarter - , subq_11.paid_at__extract_month - , subq_11.paid_at__extract_day - , subq_11.paid_at__extract_dow - , subq_11.paid_at__extract_doy - , subq_11.booking__ds__day - , subq_11.booking__ds__week - , subq_11.booking__ds__month - , subq_11.booking__ds__quarter - , subq_11.booking__ds__year - , subq_11.booking__ds__extract_year - , subq_11.booking__ds__extract_quarter - , subq_11.booking__ds__extract_month - , subq_11.booking__ds__extract_day - , subq_11.booking__ds__extract_dow - , subq_11.booking__ds__extract_doy - , subq_11.booking__ds_partitioned__day - , subq_11.booking__ds_partitioned__week - , subq_11.booking__ds_partitioned__month - , subq_11.booking__ds_partitioned__quarter - , subq_11.booking__ds_partitioned__year - , subq_11.booking__ds_partitioned__extract_year - , subq_11.booking__ds_partitioned__extract_quarter - , subq_11.booking__ds_partitioned__extract_month - , subq_11.booking__ds_partitioned__extract_day - , subq_11.booking__ds_partitioned__extract_dow - , subq_11.booking__ds_partitioned__extract_doy - , subq_11.booking__paid_at__day - , subq_11.booking__paid_at__week - , subq_11.booking__paid_at__month - , subq_11.booking__paid_at__quarter - , subq_11.booking__paid_at__year - , subq_11.booking__paid_at__extract_year - , subq_11.booking__paid_at__extract_quarter - , subq_11.booking__paid_at__extract_month - , subq_11.booking__paid_at__extract_day - , subq_11.booking__paid_at__extract_dow - , subq_11.booking__paid_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.guest - , subq_11.host - , subq_11.booking__listing - , subq_11.booking__guest - , subq_11.booking__host - , subq_11.is_instant - , subq_11.booking__is_instant - , subq_11.bookings - , subq_11.instant_bookings - , subq_11.booking_value - , subq_11.max_booking_value - , subq_11.min_booking_value - , subq_11.bookers - , subq_11.average_booking_value - , subq_11.referred_bookings - , subq_11.median_booking_value - , subq_11.booking_value_p99 - , subq_11.discrete_booking_value_p99 - , subq_11.approximate_continuous_booking_value_p99 - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -379,137 +379,137 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_13.listing - ) subq_14 - ) subq_15 - ) subq_16 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_10.listing = subq_16.listing + subq_2.listing = subq_8.listing LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookers'] SELECT - subq_21.listing - , subq_21.listing__bookers + subq_13.listing + , subq_13.listing__bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_20.listing - , subq_20.bookers AS listing__bookers + subq_12.listing + , subq_12.bookers AS listing__bookers FROM ( -- Aggregate Measures SELECT - subq_19.listing - , COUNT(DISTINCT subq_19.bookers) AS bookers + subq_11.listing + , COUNT(DISTINCT subq_11.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_18.listing - , subq_18.bookers + subq_10.listing + , subq_10.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_17.ds__day - , subq_17.ds__week - , subq_17.ds__month - , subq_17.ds__quarter - , subq_17.ds__year - , subq_17.ds__extract_year - , subq_17.ds__extract_quarter - , subq_17.ds__extract_month - , subq_17.ds__extract_day - , subq_17.ds__extract_dow - , subq_17.ds__extract_doy - , subq_17.ds_partitioned__day - , subq_17.ds_partitioned__week - , subq_17.ds_partitioned__month - , subq_17.ds_partitioned__quarter - , subq_17.ds_partitioned__year - , subq_17.ds_partitioned__extract_year - , subq_17.ds_partitioned__extract_quarter - , subq_17.ds_partitioned__extract_month - , subq_17.ds_partitioned__extract_day - , subq_17.ds_partitioned__extract_dow - , subq_17.ds_partitioned__extract_doy - , subq_17.paid_at__day - , subq_17.paid_at__week - , subq_17.paid_at__month - , subq_17.paid_at__quarter - , subq_17.paid_at__year - , subq_17.paid_at__extract_year - , subq_17.paid_at__extract_quarter - , subq_17.paid_at__extract_month - , subq_17.paid_at__extract_day - , subq_17.paid_at__extract_dow - , subq_17.paid_at__extract_doy - , subq_17.booking__ds__day - , subq_17.booking__ds__week - , subq_17.booking__ds__month - , subq_17.booking__ds__quarter - , subq_17.booking__ds__year - , subq_17.booking__ds__extract_year - , subq_17.booking__ds__extract_quarter - , subq_17.booking__ds__extract_month - , subq_17.booking__ds__extract_day - , subq_17.booking__ds__extract_dow - , subq_17.booking__ds__extract_doy - , subq_17.booking__ds_partitioned__day - , subq_17.booking__ds_partitioned__week - , subq_17.booking__ds_partitioned__month - , subq_17.booking__ds_partitioned__quarter - , subq_17.booking__ds_partitioned__year - , subq_17.booking__ds_partitioned__extract_year - , subq_17.booking__ds_partitioned__extract_quarter - , subq_17.booking__ds_partitioned__extract_month - , subq_17.booking__ds_partitioned__extract_day - , subq_17.booking__ds_partitioned__extract_dow - , subq_17.booking__ds_partitioned__extract_doy - , subq_17.booking__paid_at__day - , subq_17.booking__paid_at__week - , subq_17.booking__paid_at__month - , subq_17.booking__paid_at__quarter - , subq_17.booking__paid_at__year - , subq_17.booking__paid_at__extract_year - , subq_17.booking__paid_at__extract_quarter - , subq_17.booking__paid_at__extract_month - , subq_17.booking__paid_at__extract_day - , subq_17.booking__paid_at__extract_dow - , subq_17.booking__paid_at__extract_doy - , subq_17.ds__day AS metric_time__day - , subq_17.ds__week AS metric_time__week - , subq_17.ds__month AS metric_time__month - , subq_17.ds__quarter AS metric_time__quarter - , subq_17.ds__year AS metric_time__year - , subq_17.ds__extract_year AS metric_time__extract_year - , subq_17.ds__extract_quarter AS metric_time__extract_quarter - , subq_17.ds__extract_month AS metric_time__extract_month - , subq_17.ds__extract_day AS metric_time__extract_day - , subq_17.ds__extract_dow AS metric_time__extract_dow - , subq_17.ds__extract_doy AS metric_time__extract_doy - , subq_17.listing - , subq_17.guest - , subq_17.host - , subq_17.booking__listing - , subq_17.booking__guest - , subq_17.booking__host - , subq_17.is_instant - , subq_17.booking__is_instant - , subq_17.bookings - , subq_17.instant_bookings - , subq_17.booking_value - , subq_17.max_booking_value - , subq_17.min_booking_value - , subq_17.bookers - , subq_17.average_booking_value - , subq_17.referred_bookings - , subq_17.median_booking_value - , subq_17.booking_value_p99 - , subq_17.discrete_booking_value_p99 - , subq_17.approximate_continuous_booking_value_p99 - , subq_17.approximate_discrete_booking_value_p99 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -602,19 +602,19 @@ 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_17 - ) subq_18 - ) subq_19 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_19.listing - ) subq_20 - ) subq_21 - ) subq_22 + subq_11.listing + ) subq_12 + ) subq_13 + ) subq_14 ON - subq_10.listing = subq_22.listing - ) subq_23 - ) subq_24 + subq_2.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__bookings > 2 AND listing__bookers > 1 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql index 1846b78cd5..767f0b3fea 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_44.listing__bookings AS listing__bookings - , subq_50.listing__bookers AS listing__bookers - , subq_38.listings AS listings + subq_28.listing__bookings AS listing__bookings + , subq_34.listing__bookers AS listing__bookers + , subq_22.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -19,7 +19,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_38 + ) subq_22 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,12 +35,12 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_41 + ) subq_25 GROUP BY listing - ) subq_44 + ) subq_28 ON - subq_38.listing = subq_44.listing + subq_22.listing = subq_28.listing LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -54,8 +54,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_50 + ) subq_34 ON - subq_38.listing = subq_50.listing -) subq_52 + subq_22.listing = subq_34.listing +) subq_36 WHERE listing__bookings > 2 AND listing__bookers > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_ratio_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_ratio_metric_in_where_filter__plan0.sql index f70d45f32f..559ca2799b 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_ratio_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_ratio_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_31.listings + subq_20.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_30.listings) AS listings + SUM(subq_19.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_29.listings + subq_18.listings FROM ( -- Constrain Output with WHERE SELECT - subq_28.listing__bookings_per_booker - , subq_28.listings + subq_17.listing__bookings_per_booker + , subq_17.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - subq_27.listing__bookings_per_booker - , subq_27.listings + subq_16.listing__bookings_per_booker + , subq_16.listings FROM ( -- Join Standard Outputs SELECT - subq_13.listing AS listing - , subq_26.listing__bookings_per_booker AS listing__bookings_per_booker - , subq_13.listings AS listings + subq_2.listing AS listing + , subq_15.listing__bookings_per_booker AS listing__bookings_per_booker + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_12.listing - , subq_12.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,141 +160,141 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] SELECT - subq_25.listing - , subq_25.listing__bookings_per_booker + subq_14.listing + , subq_14.listing__bookings_per_booker FROM ( -- Compute Metrics via Expressions SELECT - subq_24.listing - , CAST(subq_24.bookings AS DOUBLE) / CAST(NULLIF(subq_24.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker + subq_13.listing + , CAST(subq_13.bookings AS DOUBLE) / CAST(NULLIF(subq_13.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.listing, subq_23.listing) AS listing - , MAX(subq_18.bookings) AS bookings - , MAX(subq_23.bookers) AS bookers + COALESCE(subq_7.listing, subq_12.listing) AS listing + , MAX(subq_7.bookings) AS bookings + , MAX(subq_12.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_17.listing - , subq_17.bookings + subq_6.listing + , subq_6.bookings FROM ( -- Aggregate Measures SELECT - subq_16.listing - , SUM(subq_16.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_15.listing - , subq_15.bookings + subq_4.listing + , subq_4.bookings 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_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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -387,129 +387,129 @@ 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_3 + ) subq_4 + ) subq_5 GROUP BY - subq_16.listing - ) subq_17 - ) subq_18 + subq_5.listing + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.listing - , subq_22.bookers + subq_11.listing + , subq_11.bookers FROM ( -- Aggregate Measures SELECT - subq_21.listing - , COUNT(DISTINCT subq_21.bookers) AS bookers + subq_10.listing + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_20.listing - , subq_20.bookers + subq_9.listing + , subq_9.bookers FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -602,25 +602,25 @@ 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_19 - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_21.listing - ) subq_22 - ) subq_23 + subq_10.listing + ) subq_11 + ) subq_12 ON - subq_18.listing = subq_23.listing + subq_7.listing = subq_12.listing GROUP BY - COALESCE(subq_18.listing, subq_23.listing) - ) subq_24 - ) subq_25 - ) subq_26 + COALESCE(subq_7.listing, subq_12.listing) + ) subq_13 + ) subq_14 + ) subq_15 ON - subq_13.listing = subq_26.listing - ) subq_27 - ) subq_28 + subq_2.listing = subq_15.listing + ) subq_16 + ) subq_17 WHERE listing__bookings_per_booker > 1 - ) subq_29 - ) subq_30 -) subq_31 + ) subq_18 + ) subq_19 +) subq_20 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql index 35d30ee209..86e90a968e 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - CAST(subq_56.bookings AS DOUBLE) / CAST(NULLIF(subq_56.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker - , subq_45.listings AS listings + CAST(subq_34.bookings AS DOUBLE) / CAST(NULLIF(subq_34.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker + , subq_23.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,13 +18,13 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_45 + ) subq_23 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_50.listing, subq_55.listing) AS listing - , MAX(subq_50.bookings) AS bookings - , MAX(subq_55.bookers) AS bookers + COALESCE(subq_28.listing, subq_33.listing) AS listing + , MAX(subq_28.bookings) AS bookings + , MAX(subq_33.bookers) AS bookers FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,10 +39,10 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_48 + ) subq_26 GROUP BY listing - ) subq_50 + ) subq_28 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -55,13 +55,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_55 + ) subq_33 ON - subq_50.listing = subq_55.listing + subq_28.listing = subq_33.listing GROUP BY - COALESCE(subq_50.listing, subq_55.listing) - ) subq_56 + COALESCE(subq_28.listing, subq_33.listing) + ) subq_34 ON - subq_45.listing = subq_56.listing -) subq_60 + subq_23.listing = subq_34.listing +) subq_38 WHERE listing__bookings_per_booker > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_simple_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_simple_metric_in_where_filter__plan0.sql index 5c4e575293..2dec46f789 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_simple_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_simple_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_17.listings + subq_13.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_16.listings) AS listings + SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_15.listings + subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.listing__bookings - , subq_14.listings + subq_10.listing__bookings + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_13.listing__bookings - , subq_13.listings + subq_9.listing__bookings + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.listing AS listing - , subq_12.listing__bookings AS listing__bookings - , subq_6.listings AS listings + subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_5.listing - , subq_5.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,130 +160,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_11.listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing - , SUM(subq_9.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_8.listing - , subq_8.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -376,19 +376,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.listing - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookings > 2 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql index 98bdb265dd..48fed36d03 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_30.listing__bookings AS listing__bookings - , subq_24.listings AS listings + subq_22.listing__bookings AS listing__bookings + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -34,11 +34,11 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_27 + ) subq_19 GROUP BY listing - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookings > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_distinct_values_query_with_metric_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_distinct_values_query_with_metric_filter__plan0.sql index 88b536d908..dbbd3a25db 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_distinct_values_query_with_metric_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_distinct_values_query_with_metric_filter__plan0.sql @@ -1,20 +1,20 @@ -- Pass Only Elements: ['listing',] SELECT - subq_12.listing + subq_8.listing FROM ( -- Constrain Output with WHERE SELECT - subq_11.listing - , subq_11.lux_listing - , subq_11.listing__lux_listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.lux_listing + , subq_7.listing__lux_listing + , subq_7.listing__bookings FROM ( -- Join Standard Outputs SELECT - subq_4.listing AS listing - , subq_4.lux_listing AS lux_listing - , subq_4.listing__lux_listing AS listing__lux_listing - , subq_10.listing__bookings AS listing__bookings + subq_0.listing AS listing + , subq_0.lux_listing AS lux_listing + , subq_0.listing__lux_listing AS listing__lux_listing + , subq_6.listing__bookings AS listing__bookings FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -22,128 +22,128 @@ FROM ( , lux_listing_mapping_src_28000.lux_listing_id AS lux_listing , lux_listing_mapping_src_28000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_28000 - ) subq_4 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_9.listing - , subq_9.listing__bookings + subq_5.listing + , subq_5.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.listing - , subq_8.bookings AS listing__bookings + subq_4.listing + , subq_4.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_7.listing - , SUM(subq_7.bookings) AS bookings + subq_3.listing + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_6.listing - , subq_6.bookings + subq_2.listing + , subq_2.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__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 + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -236,18 +236,18 @@ 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_5 - ) subq_6 - ) subq_7 + ) subq_1 + ) subq_2 + ) subq_3 GROUP BY - subq_7.listing - ) subq_8 - ) subq_9 - ) subq_10 + subq_3.listing + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_4.listing = subq_10.listing - ) subq_11 + subq_0.listing = subq_6.listing + ) subq_7 WHERE listing__bookings > 2 -) subq_12 +) subq_8 GROUP BY - subq_12.listing + subq_8.listing diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_distinct_values_query_with_metric_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_distinct_values_query_with_metric_filter__plan0_optimized.sql index cde9c960c5..d79ef0aa09 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_distinct_values_query_with_metric_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_distinct_values_query_with_metric_filter__plan0_optimized.sql @@ -6,7 +6,7 @@ FROM ( -- Join Standard Outputs SELECT lux_listing_mapping_src_28000.listing_id AS listing - , subq_23.listing__bookings AS listing__bookings + , subq_15.listing__bookings AS listing__bookings FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_28000 FULL OUTER JOIN ( -- Aggregate Measures @@ -23,13 +23,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_20 + ) subq_12 GROUP BY listing - ) subq_23 + ) subq_15 ON - lux_listing_mapping_src_28000.listing_id = subq_23.listing -) subq_24 + lux_listing_mapping_src_28000.listing_id = subq_15.listing +) subq_16 WHERE listing__bookings > 2 GROUP BY listing diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql index efa1b2b2fa..65c15f1222 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql @@ -1,136 +1,136 @@ -- Compute Metrics via Expressions SELECT - subq_17.bookers + subq_13.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_16.bookers) AS bookers + COUNT(DISTINCT subq_12.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_15.bookers + subq_11.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_14.guest__booking_value - , subq_14.bookers + subq_10.guest__booking_value + , subq_10.bookers FROM ( -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_13.guest__booking_value - , subq_13.bookers + subq_9.guest__booking_value + , subq_9.bookers FROM ( -- Join Standard Outputs SELECT - subq_6.guest AS guest - , subq_12.guest__booking_value AS guest__booking_value - , subq_6.bookers AS bookers + subq_2.guest AS guest + , subq_8.guest__booking_value AS guest__booking_value + , subq_2.bookers AS bookers FROM ( -- Pass Only Elements: ['bookers', 'guest'] SELECT - subq_5.guest - , subq_5.bookers + subq_1.guest + , subq_1.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -223,130 +223,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['guest', 'guest__booking_value'] SELECT - subq_11.guest - , subq_11.guest__booking_value + subq_7.guest + , subq_7.guest__booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.guest - , subq_10.booking_value AS guest__booking_value + subq_6.guest + , subq_6.booking_value AS guest__booking_value FROM ( -- Aggregate Measures SELECT - subq_9.guest - , SUM(subq_9.booking_value) AS booking_value + subq_5.guest + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'guest'] SELECT - subq_8.guest - , subq_8.booking_value + subq_4.guest + , subq_4.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -439,19 +439,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.guest - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.guest + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.guest = subq_12.guest - ) subq_13 - ) subq_14 + subq_2.guest = subq_8.guest + ) subq_9 + ) subq_10 WHERE guest__booking_value > 1.00 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql index 7df3ce4738..93d184feee 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_30.guest__booking_value AS guest__booking_value - , subq_24.bookers AS bookers + subq_22.guest__booking_value AS guest__booking_value + , subq_16.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( guest_id AS guest , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY guest_id - ) subq_30 + ) subq_22 ON - subq_24.guest = subq_30.guest -) subq_32 + subq_16.guest = subq_22.guest +) subq_24 WHERE guest__booking_value > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_with_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_with_conversion_metric__plan0.sql index 35aafc5d9a..673491a08a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_with_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_with_conversion_metric__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_39.listings + subq_24.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_38.listings) AS listings + SUM(subq_23.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_37.listings + subq_22.listings FROM ( -- Constrain Output with WHERE SELECT - subq_36.user__visit_buy_conversion_rate - , subq_36.listings + subq_21.user__visit_buy_conversion_rate + , subq_21.listings FROM ( -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - subq_35.user__visit_buy_conversion_rate - , subq_35.listings + subq_20.user__visit_buy_conversion_rate + , subq_20.listings FROM ( -- Join Standard Outputs SELECT - subq_17.user AS user - , subq_34.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate - , subq_17.listings AS listings + subq_2.user AS user + , subq_19.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_16.user - , subq_16.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,79 +160,79 @@ 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_15 - ) subq_16 - ) subq_17 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] SELECT - subq_33.user - , subq_33.user__visit_buy_conversion_rate + subq_18.user + , subq_18.user__visit_buy_conversion_rate FROM ( -- Compute Metrics via Expressions SELECT - subq_32.user - , CAST(subq_32.buys AS DOUBLE) / CAST(NULLIF(subq_32.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate + subq_17.user + , CAST(subq_17.buys AS DOUBLE) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.user, subq_31.user) AS user - , MAX(subq_21.visits) AS visits - , MAX(subq_31.buys) AS buys + COALESCE(subq_6.user, subq_16.user) AS user + , MAX(subq_6.visits) AS visits + , MAX(subq_16.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_20.user - , SUM(subq_20.visits) AS visits + subq_5.user + , SUM(subq_5.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'user'] SELECT - subq_19.user - , subq_19.visits + subq_4.user + , subq_4.visits 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.visit__ds__day - , subq_18.visit__ds__week - , subq_18.visit__ds__month - , subq_18.visit__ds__quarter - , subq_18.visit__ds__year - , subq_18.visit__ds__extract_year - , subq_18.visit__ds__extract_quarter - , subq_18.visit__ds__extract_month - , subq_18.visit__ds__extract_day - , subq_18.visit__ds__extract_dow - , subq_18.visit__ds__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.user - , subq_18.session - , subq_18.visit__user - , subq_18.visit__session - , subq_18.referrer_id - , subq_18.visit__referrer_id - , subq_18.visits - , subq_18.visitors + 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.visit__ds__day + , subq_3.visit__ds__week + , subq_3.visit__ds__month + , subq_3.visit__ds__quarter + , subq_3.visit__ds__year + , subq_3.visit__ds__extract_year + , subq_3.visit__ds__extract_quarter + , subq_3.visit__ds__extract_month + , subq_3.visit__ds__extract_day + , subq_3.visit__ds__extract_dow + , subq_3.visit__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_3.user + , subq_3.session + , subq_3.visit__user + , subq_3.visit__session + , subq_3.referrer_id + , subq_3.visit__referrer_id + , subq_3.visits + , subq_3.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -267,108 +267,108 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_18 - ) subq_19 - ) subq_20 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_20.user - ) subq_21 + subq_5.user + ) subq_6 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_30.user - , SUM(subq_30.buys) AS buys + subq_15.user + , SUM(subq_15.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'user'] SELECT - subq_29.user - , subq_29.buys + subq_14.user + , subq_14.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_28.ds__day - , subq_28.user - , subq_28.buys - , subq_28.visits + subq_13.ds__day + , subq_13.user + , subq_13.buys + , subq_13.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_24.visits) OVER ( + first_value(subq_9.visits) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_24.ds__day) OVER ( + , first_value(subq_9.ds__day) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_24.user) OVER ( + , first_value(subq_9.user) OVER ( PARTITION BY - subq_27.user - , subq_27.ds__day - , subq_27.mf_internal_uuid - ORDER BY subq_24.ds__day DESC + subq_12.user + , subq_12.ds__day + , subq_12.mf_internal_uuid + ORDER BY subq_9.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_27.mf_internal_uuid AS mf_internal_uuid - , subq_27.buys AS buys + , subq_12.mf_internal_uuid AS mf_internal_uuid + , subq_12.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'ds__day', 'user'] SELECT - subq_23.ds__day - , subq_23.user - , subq_23.visits + subq_8.ds__day + , subq_8.user + , subq_8.visits 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.visit__ds__day - , subq_22.visit__ds__week - , subq_22.visit__ds__month - , subq_22.visit__ds__quarter - , subq_22.visit__ds__year - , subq_22.visit__ds__extract_year - , subq_22.visit__ds__extract_quarter - , subq_22.visit__ds__extract_month - , subq_22.visit__ds__extract_day - , subq_22.visit__ds__extract_dow - , subq_22.visit__ds__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.user - , subq_22.session - , subq_22.visit__user - , subq_22.visit__session - , subq_22.referrer_id - , subq_22.visit__referrer_id - , subq_22.visits - , subq_22.visitors + 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.visit__ds__day + , subq_7.visit__ds__week + , subq_7.visit__ds__month + , subq_7.visit__ds__quarter + , subq_7.visit__ds__year + , subq_7.visit__ds__extract_year + , subq_7.visit__ds__extract_quarter + , subq_7.visit__ds__extract_month + , subq_7.visit__ds__extract_day + , subq_7.visit__ds__extract_dow + , subq_7.visit__ds__extract_doy + , subq_7.ds__day AS metric_time__day + , subq_7.ds__week AS metric_time__week + , subq_7.ds__month AS metric_time__month + , subq_7.ds__quarter AS metric_time__quarter + , subq_7.ds__year AS metric_time__year + , subq_7.ds__extract_year AS metric_time__extract_year + , subq_7.ds__extract_quarter AS metric_time__extract_quarter + , subq_7.ds__extract_month AS metric_time__extract_month + , subq_7.ds__extract_day AS metric_time__extract_day + , subq_7.ds__extract_dow AS metric_time__extract_dow + , subq_7.ds__extract_doy AS metric_time__extract_doy + , subq_7.user + , subq_7.session + , subq_7.visit__user + , subq_7.visit__session + , subq_7.referrer_id + , subq_7.visit__referrer_id + , subq_7.visits + , subq_7.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -403,94 +403,94 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_22 - ) subq_23 - ) subq_24 + ) subq_7 + ) subq_8 + ) subq_9 INNER JOIN ( -- Add column with generated UUID SELECT - subq_26.ds__day - , subq_26.ds__week - , subq_26.ds__month - , subq_26.ds__quarter - , subq_26.ds__year - , subq_26.ds__extract_year - , subq_26.ds__extract_quarter - , subq_26.ds__extract_month - , subq_26.ds__extract_day - , subq_26.ds__extract_dow - , subq_26.ds__extract_doy - , subq_26.buy__ds__day - , subq_26.buy__ds__week - , subq_26.buy__ds__month - , subq_26.buy__ds__quarter - , subq_26.buy__ds__year - , subq_26.buy__ds__extract_year - , subq_26.buy__ds__extract_quarter - , subq_26.buy__ds__extract_month - , subq_26.buy__ds__extract_day - , subq_26.buy__ds__extract_dow - , subq_26.buy__ds__extract_doy - , subq_26.metric_time__day - , subq_26.metric_time__week - , subq_26.metric_time__month - , subq_26.metric_time__quarter - , subq_26.metric_time__year - , subq_26.metric_time__extract_year - , subq_26.metric_time__extract_quarter - , subq_26.metric_time__extract_month - , subq_26.metric_time__extract_day - , subq_26.metric_time__extract_dow - , subq_26.metric_time__extract_doy - , subq_26.user - , subq_26.session_id - , subq_26.buy__user - , subq_26.buy__session_id - , subq_26.buys - , subq_26.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.metric_time__day + , subq_11.metric_time__week + , subq_11.metric_time__month + , subq_11.metric_time__quarter + , subq_11.metric_time__year + , subq_11.metric_time__extract_year + , subq_11.metric_time__extract_quarter + , subq_11.metric_time__extract_month + , subq_11.metric_time__extract_day + , subq_11.metric_time__extract_dow + , subq_11.metric_time__extract_doy + , subq_11.user + , subq_11.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers , uuid() AS mf_internal_uuid FROM ( -- Metric Time Dimension 'ds' SELECT - subq_25.ds__day - , subq_25.ds__week - , subq_25.ds__month - , subq_25.ds__quarter - , subq_25.ds__year - , subq_25.ds__extract_year - , subq_25.ds__extract_quarter - , subq_25.ds__extract_month - , subq_25.ds__extract_day - , subq_25.ds__extract_dow - , subq_25.ds__extract_doy - , subq_25.buy__ds__day - , subq_25.buy__ds__week - , subq_25.buy__ds__month - , subq_25.buy__ds__quarter - , subq_25.buy__ds__year - , subq_25.buy__ds__extract_year - , subq_25.buy__ds__extract_quarter - , subq_25.buy__ds__extract_month - , subq_25.buy__ds__extract_day - , subq_25.buy__ds__extract_dow - , subq_25.buy__ds__extract_doy - , subq_25.ds__day AS metric_time__day - , subq_25.ds__week AS metric_time__week - , subq_25.ds__month AS metric_time__month - , subq_25.ds__quarter AS metric_time__quarter - , subq_25.ds__year AS metric_time__year - , subq_25.ds__extract_year AS metric_time__extract_year - , subq_25.ds__extract_quarter AS metric_time__extract_quarter - , subq_25.ds__extract_month AS metric_time__extract_month - , subq_25.ds__extract_day AS metric_time__extract_day - , subq_25.ds__extract_dow AS metric_time__extract_dow - , subq_25.ds__extract_doy AS metric_time__extract_doy - , subq_25.user - , subq_25.session_id - , subq_25.buy__user - , subq_25.buy__session_id - , subq_25.buys - , subq_25.buyers + 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.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -523,33 +523,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_25 - ) subq_26 - ) subq_27 + ) subq_10 + ) subq_11 + ) subq_12 ON ( - subq_24.user = subq_27.user + subq_9.user = subq_12.user ) AND ( - (subq_24.ds__day <= subq_27.ds__day) + (subq_9.ds__day <= subq_12.ds__day) ) - ) subq_28 - ) subq_29 - ) subq_30 + ) subq_13 + ) subq_14 + ) subq_15 GROUP BY - subq_30.user - ) subq_31 + subq_15.user + ) subq_16 ON - subq_21.user = subq_31.user + subq_6.user = subq_16.user GROUP BY - COALESCE(subq_21.user, subq_31.user) - ) subq_32 - ) subq_33 - ) subq_34 + COALESCE(subq_6.user, subq_16.user) + ) subq_17 + ) subq_18 + ) subq_19 ON - subq_17.user = subq_34.user - ) subq_35 - ) subq_36 + subq_2.user = subq_19.user + ) subq_20 + ) subq_21 WHERE user__visit_buy_conversion_rate > 2 - ) subq_37 - ) subq_38 -) subq_39 + ) subq_22 + ) subq_23 +) subq_24 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_with_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_with_conversion_metric__plan0_optimized.sql index 67e7da2f2b..133b0baf75 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_with_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_with_conversion_metric__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - CAST(subq_72.buys AS DOUBLE) / CAST(NULLIF(subq_72.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate - , subq_57.listings AS listings + CAST(subq_42.buys AS DOUBLE) / CAST(NULLIF(subq_42.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate + , subq_27.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,17 +18,17 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_57 + ) subq_27 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_61.user, subq_71.user) AS user - , MAX(subq_61.visits) AS visits - , MAX(subq_71.buys) AS buys + COALESCE(subq_31.user, subq_41.user) AS user + , MAX(subq_31.visits) AS visits + , MAX(subq_41.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_60.user + subq_30.user , SUM(visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -38,46 +38,46 @@ FROM ( user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_60 + ) subq_30 GROUP BY - subq_60.user - ) subq_61 + subq_30.user + ) subq_31 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'user'] -- Aggregate Measures SELECT - subq_68.user + subq_38.user , SUM(buys) AS buys FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - first_value(subq_64.visits) OVER ( + first_value(subq_34.visits) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , first_value(subq_64.ds__day) OVER ( + , first_value(subq_34.ds__day) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS ds__day - , first_value(subq_64.user) OVER ( + , first_value(subq_34.user) OVER ( PARTITION BY - subq_67.user - , subq_67.ds__day - , subq_67.mf_internal_uuid - ORDER BY subq_64.ds__day DESC + subq_37.user + , subq_37.ds__day + , subq_37.mf_internal_uuid + ORDER BY subq_34.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_67.mf_internal_uuid AS mf_internal_uuid - , subq_67.buys AS buys + , subq_37.mf_internal_uuid AS mf_internal_uuid + , subq_37.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -87,7 +87,7 @@ FROM ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_64 + ) subq_34 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -98,23 +98,23 @@ FROM ( , 1 AS buys , uuid() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_67 + ) subq_37 ON ( - subq_64.user = subq_67.user + subq_34.user = subq_37.user ) AND ( - (subq_64.ds__day <= subq_67.ds__day) + (subq_34.ds__day <= subq_37.ds__day) ) - ) subq_68 + ) subq_38 GROUP BY - subq_68.user - ) subq_71 + subq_38.user + ) subq_41 ON - subq_61.user = subq_71.user + subq_31.user = subq_41.user GROUP BY - COALESCE(subq_61.user, subq_71.user) - ) subq_72 + COALESCE(subq_31.user, subq_41.user) + ) subq_42 ON - subq_57.user = subq_72.user -) subq_76 + subq_27.user = subq_42.user +) subq_46 WHERE user__visit_buy_conversion_rate > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_group_by_has_local_entity_prefix__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_group_by_has_local_entity_prefix__plan0.sql index 2cfabce1f1..3bf96a545f 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_group_by_has_local_entity_prefix__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_group_by_has_local_entity_prefix__plan0.sql @@ -1,106 +1,106 @@ -- Compute Metrics via Expressions SELECT - subq_27.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_26.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_25.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_24.user__listing__user__average_booking_value - , subq_24.listings + subq_15.user__listing__user__average_booking_value + , subq_15.listings FROM ( -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_23.user__listing__user__average_booking_value - , subq_23.listings + subq_14.user__listing__user__average_booking_value + , subq_14.listings FROM ( -- Join Standard Outputs SELECT - subq_11.user AS user - , subq_22.listing__user AS user__listing__user - , subq_22.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_11.listings AS listings + subq_2.user AS user + , subq_13.listing__user AS user__listing__user + , subq_13.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_10.user - , subq_10.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__extract_quarter - , subq_9.ds__extract_month - , subq_9.ds__extract_day - , subq_9.ds__extract_dow - , subq_9.ds__extract_doy - , subq_9.created_at__day - , subq_9.created_at__week - , subq_9.created_at__month - , subq_9.created_at__quarter - , subq_9.created_at__year - , subq_9.created_at__extract_year - , subq_9.created_at__extract_quarter - , subq_9.created_at__extract_month - , subq_9.created_at__extract_day - , subq_9.created_at__extract_dow - , subq_9.created_at__extract_doy - , subq_9.listing__ds__day - , subq_9.listing__ds__week - , subq_9.listing__ds__month - , subq_9.listing__ds__quarter - , subq_9.listing__ds__year - , subq_9.listing__ds__extract_year - , subq_9.listing__ds__extract_quarter - , subq_9.listing__ds__extract_month - , subq_9.listing__ds__extract_day - , subq_9.listing__ds__extract_dow - , subq_9.listing__ds__extract_doy - , subq_9.listing__created_at__day - , subq_9.listing__created_at__week - , subq_9.listing__created_at__month - , subq_9.listing__created_at__quarter - , subq_9.listing__created_at__year - , subq_9.listing__created_at__extract_year - , subq_9.listing__created_at__extract_quarter - , subq_9.listing__created_at__extract_month - , subq_9.listing__created_at__extract_day - , subq_9.listing__created_at__extract_dow - , subq_9.listing__created_at__extract_doy - , subq_9.ds__day AS metric_time__day - , subq_9.ds__week AS metric_time__week - , subq_9.ds__month AS metric_time__month - , subq_9.ds__quarter AS metric_time__quarter - , subq_9.ds__year AS metric_time__year - , subq_9.ds__extract_year AS metric_time__extract_year - , subq_9.ds__extract_quarter AS metric_time__extract_quarter - , subq_9.ds__extract_month AS metric_time__extract_month - , subq_9.ds__extract_day AS metric_time__extract_day - , subq_9.ds__extract_dow AS metric_time__extract_dow - , subq_9.ds__extract_doy AS metric_time__extract_doy - , subq_9.listing - , subq_9.user - , subq_9.listing__user - , subq_9.country_latest - , subq_9.is_lux_latest - , subq_9.capacity_latest - , subq_9.listing__country_latest - , subq_9.listing__is_lux_latest - , subq_9.listing__capacity_latest - , subq_9.listings - , subq_9.largest_listing - , subq_9.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -161,141 +161,141 @@ 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_9 - ) subq_10 - ) subq_11 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] SELECT - subq_21.listing__user - , subq_21.listing__user__average_booking_value + subq_12.listing__user + , subq_12.listing__user__average_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_20.listing__user - , subq_20.average_booking_value AS listing__user__average_booking_value + subq_11.listing__user + , subq_11.average_booking_value AS listing__user__average_booking_value FROM ( -- Aggregate Measures SELECT - subq_19.listing__user - , AVG(subq_19.average_booking_value) AS average_booking_value + subq_10.listing__user + , AVG(subq_10.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__user'] SELECT - subq_18.listing__user - , subq_18.average_booking_value + subq_9.listing__user + , subq_9.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_14.listing AS listing - , subq_17.user AS listing__user - , subq_14.average_booking_value AS average_booking_value + subq_5.listing AS listing + , subq_8.user AS listing__user + , subq_5.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing'] SELECT - subq_13.listing - , subq_13.average_booking_value + subq_4.listing + , subq_4.average_booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_12.ds__day - , subq_12.ds__week - , subq_12.ds__month - , subq_12.ds__quarter - , subq_12.ds__year - , subq_12.ds__extract_year - , subq_12.ds__extract_quarter - , subq_12.ds__extract_month - , subq_12.ds__extract_day - , subq_12.ds__extract_dow - , subq_12.ds__extract_doy - , subq_12.ds_partitioned__day - , subq_12.ds_partitioned__week - , subq_12.ds_partitioned__month - , subq_12.ds_partitioned__quarter - , subq_12.ds_partitioned__year - , subq_12.ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy - , subq_12.paid_at__day - , subq_12.paid_at__week - , subq_12.paid_at__month - , subq_12.paid_at__quarter - , subq_12.paid_at__year - , subq_12.paid_at__extract_year - , subq_12.paid_at__extract_quarter - , subq_12.paid_at__extract_month - , subq_12.paid_at__extract_day - , subq_12.paid_at__extract_dow - , subq_12.paid_at__extract_doy - , subq_12.booking__ds__day - , subq_12.booking__ds__week - , subq_12.booking__ds__month - , subq_12.booking__ds__quarter - , subq_12.booking__ds__year - , subq_12.booking__ds__extract_year - , subq_12.booking__ds__extract_quarter - , subq_12.booking__ds__extract_month - , subq_12.booking__ds__extract_day - , subq_12.booking__ds__extract_dow - , subq_12.booking__ds__extract_doy - , subq_12.booking__ds_partitioned__day - , subq_12.booking__ds_partitioned__week - , subq_12.booking__ds_partitioned__month - , subq_12.booking__ds_partitioned__quarter - , subq_12.booking__ds_partitioned__year - , subq_12.booking__ds_partitioned__extract_year - , subq_12.booking__ds_partitioned__extract_quarter - , subq_12.booking__ds_partitioned__extract_month - , subq_12.booking__ds_partitioned__extract_day - , subq_12.booking__ds_partitioned__extract_dow - , subq_12.booking__ds_partitioned__extract_doy - , subq_12.booking__paid_at__day - , subq_12.booking__paid_at__week - , subq_12.booking__paid_at__month - , subq_12.booking__paid_at__quarter - , subq_12.booking__paid_at__year - , subq_12.booking__paid_at__extract_year - , subq_12.booking__paid_at__extract_quarter - , subq_12.booking__paid_at__extract_month - , subq_12.booking__paid_at__extract_day - , subq_12.booking__paid_at__extract_dow - , subq_12.booking__paid_at__extract_doy - , subq_12.ds__day AS metric_time__day - , subq_12.ds__week AS metric_time__week - , subq_12.ds__month AS metric_time__month - , subq_12.ds__quarter AS metric_time__quarter - , subq_12.ds__year AS metric_time__year - , subq_12.ds__extract_year AS metric_time__extract_year - , subq_12.ds__extract_quarter AS metric_time__extract_quarter - , subq_12.ds__extract_month AS metric_time__extract_month - , subq_12.ds__extract_day AS metric_time__extract_day - , subq_12.ds__extract_dow AS metric_time__extract_dow - , subq_12.ds__extract_doy AS metric_time__extract_doy - , subq_12.listing - , subq_12.guest - , subq_12.host - , subq_12.booking__listing - , subq_12.booking__guest - , subq_12.booking__host - , subq_12.is_instant - , subq_12.booking__is_instant - , subq_12.bookings - , subq_12.instant_bookings - , subq_12.booking_value - , subq_12.max_booking_value - , subq_12.min_booking_value - , subq_12.bookers - , subq_12.average_booking_value - , subq_12.referred_bookings - , subq_12.median_booking_value - , subq_12.booking_value_p99 - , subq_12.discrete_booking_value_p99 - , subq_12.approximate_continuous_booking_value_p99 - , subq_12.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -388,84 +388,84 @@ 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_12 - ) subq_13 - ) subq_14 + ) subq_3 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'user'] SELECT - subq_16.listing - , subq_16.user + subq_7.listing + , subq_7.user FROM ( -- Metric Time Dimension 'ds' SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.created_at__day - , subq_15.created_at__week - , subq_15.created_at__month - , subq_15.created_at__quarter - , subq_15.created_at__year - , subq_15.created_at__extract_year - , subq_15.created_at__extract_quarter - , subq_15.created_at__extract_month - , subq_15.created_at__extract_day - , subq_15.created_at__extract_dow - , subq_15.created_at__extract_doy - , subq_15.listing__ds__day - , subq_15.listing__ds__week - , subq_15.listing__ds__month - , subq_15.listing__ds__quarter - , subq_15.listing__ds__year - , subq_15.listing__ds__extract_year - , subq_15.listing__ds__extract_quarter - , subq_15.listing__ds__extract_month - , subq_15.listing__ds__extract_day - , subq_15.listing__ds__extract_dow - , subq_15.listing__ds__extract_doy - , subq_15.listing__created_at__day - , subq_15.listing__created_at__week - , subq_15.listing__created_at__month - , subq_15.listing__created_at__quarter - , subq_15.listing__created_at__year - , subq_15.listing__created_at__extract_year - , subq_15.listing__created_at__extract_quarter - , subq_15.listing__created_at__extract_month - , subq_15.listing__created_at__extract_day - , subq_15.listing__created_at__extract_dow - , subq_15.listing__created_at__extract_doy - , subq_15.ds__day AS metric_time__day - , subq_15.ds__week AS metric_time__week - , subq_15.ds__month AS metric_time__month - , subq_15.ds__quarter AS metric_time__quarter - , subq_15.ds__year AS metric_time__year - , subq_15.ds__extract_year AS metric_time__extract_year - , subq_15.ds__extract_quarter AS metric_time__extract_quarter - , subq_15.ds__extract_month AS metric_time__extract_month - , subq_15.ds__extract_day AS metric_time__extract_day - , subq_15.ds__extract_dow AS metric_time__extract_dow - , subq_15.ds__extract_doy AS metric_time__extract_doy - , subq_15.listing - , subq_15.user - , subq_15.listing__user - , subq_15.country_latest - , subq_15.is_lux_latest - , subq_15.capacity_latest - , subq_15.listing__country_latest - , subq_15.listing__is_lux_latest - , subq_15.listing__capacity_latest - , subq_15.listings - , subq_15.largest_listing - , subq_15.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 @@ -526,23 +526,23 @@ 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_15 - ) subq_16 - ) subq_17 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + subq_5.listing = subq_8.listing + ) subq_9 + ) subq_10 GROUP BY - subq_19.listing__user - ) subq_20 - ) subq_21 - ) subq_22 + subq_10.listing__user + ) subq_11 + ) subq_12 + ) subq_13 ON - subq_11.user = subq_22.listing__user - ) subq_23 - ) subq_24 + subq_2.user = subq_13.listing__user + ) subq_14 + ) subq_15 WHERE user__listing__user__average_booking_value > 1 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_group_by_has_local_entity_prefix__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_group_by_has_local_entity_prefix__plan0_optimized.sql index f2d9e26580..8a2de81699 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_group_by_has_local_entity_prefix__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_group_by_has_local_entity_prefix__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_50.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_39.listings AS listings + subq_32.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_21.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_39 + ) subq_21 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__user'] @@ -35,8 +35,8 @@ FROM ( bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY listings_latest_src_28000.user_id - ) subq_50 + ) subq_32 ON - subq_39.user = subq_50.listing__user -) subq_52 + subq_21.user = subq_32.listing__user +) subq_34 WHERE user__listing__user__average_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_multi_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_multi_hop__plan0.sql index 821ca74e2c..0ac729d058 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_multi_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_multi_hop__plan0.sql @@ -1,76 +1,76 @@ -- Compute Metrics via Expressions SELECT - subq_40.third_hop_count + subq_22.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_39.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_21.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_38.third_hop_count + subq_20.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_37.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_37.third_hop_count + subq_19.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_19.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_36.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_36.third_hop_count + subq_18.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_18.third_hop_count FROM ( -- Join Standard Outputs SELECT - subq_20.customer_third_hop_id AS customer_third_hop_id - , subq_35.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id - , subq_35.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_20.third_hop_count AS third_hop_count + subq_2.customer_third_hop_id AS customer_third_hop_id + , subq_17.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_17.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_2.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_19.customer_third_hop_id - , subq_19.third_hop_count + subq_1.customer_third_hop_id + , subq_1.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - subq_18.third_hop_ds__day - , subq_18.third_hop_ds__week - , subq_18.third_hop_ds__month - , subq_18.third_hop_ds__quarter - , subq_18.third_hop_ds__year - , subq_18.third_hop_ds__extract_year - , subq_18.third_hop_ds__extract_quarter - , subq_18.third_hop_ds__extract_month - , subq_18.third_hop_ds__extract_day - , subq_18.third_hop_ds__extract_dow - , subq_18.third_hop_ds__extract_doy - , subq_18.customer_third_hop_id__third_hop_ds__day - , subq_18.customer_third_hop_id__third_hop_ds__week - , subq_18.customer_third_hop_id__third_hop_ds__month - , subq_18.customer_third_hop_id__third_hop_ds__quarter - , subq_18.customer_third_hop_id__third_hop_ds__year - , subq_18.customer_third_hop_id__third_hop_ds__extract_year - , subq_18.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_18.customer_third_hop_id__third_hop_ds__extract_month - , subq_18.customer_third_hop_id__third_hop_ds__extract_day - , subq_18.customer_third_hop_id__third_hop_ds__extract_dow - , subq_18.customer_third_hop_id__third_hop_ds__extract_doy - , subq_18.third_hop_ds__day AS metric_time__day - , subq_18.third_hop_ds__week AS metric_time__week - , subq_18.third_hop_ds__month AS metric_time__month - , subq_18.third_hop_ds__quarter AS metric_time__quarter - , subq_18.third_hop_ds__year AS metric_time__year - , subq_18.third_hop_ds__extract_year AS metric_time__extract_year - , subq_18.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_18.third_hop_ds__extract_month AS metric_time__extract_month - , subq_18.third_hop_ds__extract_day AS metric_time__extract_day - , subq_18.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_18.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_18.customer_third_hop_id - , subq_18.value - , subq_18.customer_third_hop_id__value - , subq_18.third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( -- Read Elements From Semantic Model 'third_hop_table' SELECT @@ -101,105 +101,105 @@ 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_18 - ) subq_19 - ) subq_20 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_34.account_id__customer_id__customer_third_hop_id - , subq_34.account_id__customer_id__customer_third_hop_id__txn_count + subq_16.account_id__customer_id__customer_third_hop_id + , subq_16.account_id__customer_id__customer_third_hop_id__txn_count FROM ( -- Compute Metrics via Expressions SELECT - subq_33.account_id__customer_id__customer_third_hop_id - , subq_33.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count + subq_15.account_id__customer_id__customer_third_hop_id + , subq_15.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count FROM ( -- Aggregate Measures SELECT - subq_32.account_id__customer_id__customer_third_hop_id - , SUM(subq_32.txn_count) AS txn_count + subq_14.account_id__customer_id__customer_third_hop_id + , SUM(subq_14.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] SELECT - subq_31.account_id__customer_id__customer_third_hop_id - , subq_31.txn_count + subq_13.account_id__customer_id__customer_third_hop_id + , subq_13.txn_count FROM ( -- Join Standard Outputs SELECT - subq_23.ds_partitioned__day AS ds_partitioned__day - , subq_30.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_23.account_id AS account_id - , subq_30.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id - , subq_23.txn_count AS txn_count + subq_5.ds_partitioned__day AS ds_partitioned__day + , subq_12.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_5.account_id AS account_id + , subq_12.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + , subq_5.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_22.ds_partitioned__day - , subq_22.account_id - , subq_22.txn_count + subq_4.ds_partitioned__day + , subq_4.account_id + , subq_4.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_21.ds_partitioned__day - , subq_21.ds_partitioned__week - , subq_21.ds_partitioned__month - , subq_21.ds_partitioned__quarter - , subq_21.ds_partitioned__year - , subq_21.ds_partitioned__extract_year - , subq_21.ds_partitioned__extract_quarter - , subq_21.ds_partitioned__extract_month - , subq_21.ds_partitioned__extract_day - , subq_21.ds_partitioned__extract_dow - , subq_21.ds_partitioned__extract_doy - , subq_21.ds__day - , subq_21.ds__week - , subq_21.ds__month - , subq_21.ds__quarter - , subq_21.ds__year - , subq_21.ds__extract_year - , subq_21.ds__extract_quarter - , subq_21.ds__extract_month - , subq_21.ds__extract_day - , subq_21.ds__extract_dow - , subq_21.ds__extract_doy - , subq_21.account_id__ds_partitioned__day - , subq_21.account_id__ds_partitioned__week - , subq_21.account_id__ds_partitioned__month - , subq_21.account_id__ds_partitioned__quarter - , subq_21.account_id__ds_partitioned__year - , subq_21.account_id__ds_partitioned__extract_year - , subq_21.account_id__ds_partitioned__extract_quarter - , subq_21.account_id__ds_partitioned__extract_month - , subq_21.account_id__ds_partitioned__extract_day - , subq_21.account_id__ds_partitioned__extract_dow - , subq_21.account_id__ds_partitioned__extract_doy - , subq_21.account_id__ds__day - , subq_21.account_id__ds__week - , subq_21.account_id__ds__month - , subq_21.account_id__ds__quarter - , subq_21.account_id__ds__year - , subq_21.account_id__ds__extract_year - , subq_21.account_id__ds__extract_quarter - , subq_21.account_id__ds__extract_month - , subq_21.account_id__ds__extract_day - , subq_21.account_id__ds__extract_dow - , subq_21.account_id__ds__extract_doy - , subq_21.ds__day AS metric_time__day - , subq_21.ds__week AS metric_time__week - , subq_21.ds__month AS metric_time__month - , subq_21.ds__quarter AS metric_time__quarter - , subq_21.ds__year AS metric_time__year - , subq_21.ds__extract_year AS metric_time__extract_year - , subq_21.ds__extract_quarter AS metric_time__extract_quarter - , subq_21.ds__extract_month AS metric_time__extract_month - , subq_21.ds__extract_day AS metric_time__extract_day - , subq_21.ds__extract_dow AS metric_time__extract_dow - , subq_21.ds__extract_doy AS metric_time__extract_doy - , subq_21.account_id - , subq_21.account_month - , subq_21.account_id__account_month - , subq_21.txn_count + 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.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.account_id__ds_partitioned__day + , subq_3.account_id__ds_partitioned__week + , subq_3.account_id__ds_partitioned__month + , subq_3.account_id__ds_partitioned__quarter + , subq_3.account_id__ds_partitioned__year + , subq_3.account_id__ds_partitioned__extract_year + , subq_3.account_id__ds_partitioned__extract_quarter + , subq_3.account_id__ds_partitioned__extract_month + , subq_3.account_id__ds_partitioned__extract_day + , subq_3.account_id__ds_partitioned__extract_dow + , subq_3.account_id__ds_partitioned__extract_doy + , subq_3.account_id__ds__day + , subq_3.account_id__ds__week + , subq_3.account_id__ds__month + , subq_3.account_id__ds__quarter + , subq_3.account_id__ds__year + , subq_3.account_id__ds__extract_year + , subq_3.account_id__ds__extract_quarter + , subq_3.account_id__ds__extract_month + , subq_3.account_id__ds__extract_day + , subq_3.account_id__ds__extract_dow + , subq_3.account_id__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_3.account_id + , subq_3.account_month + , subq_3.account_id__account_month + , subq_3.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -252,164 +252,164 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_3 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] SELECT - subq_29.ds_partitioned__day - , subq_29.account_id - , subq_29.customer_id__customer_third_hop_id + subq_11.ds_partitioned__day + , subq_11.account_id + , subq_11.customer_id__customer_third_hop_id FROM ( -- Join Standard Outputs SELECT - subq_25.ds_partitioned__day AS ds_partitioned__day - , subq_25.ds_partitioned__week AS ds_partitioned__week - , subq_25.ds_partitioned__month AS ds_partitioned__month - , subq_25.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_25.ds_partitioned__year AS ds_partitioned__year - , subq_25.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_25.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_25.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_25.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_25.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_25.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_25.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_25.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_25.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_25.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_25.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_25.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_25.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_25.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_25.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_25.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_25.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_25.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_25.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_25.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_25.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_25.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_25.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_25.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_25.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_25.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_25.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_25.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_25.metric_time__day AS metric_time__day - , subq_25.metric_time__week AS metric_time__week - , subq_25.metric_time__month AS metric_time__month - , subq_25.metric_time__quarter AS metric_time__quarter - , subq_25.metric_time__year AS metric_time__year - , subq_25.metric_time__extract_year AS metric_time__extract_year - , subq_25.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_25.metric_time__extract_month AS metric_time__extract_month - , subq_25.metric_time__extract_day AS metric_time__extract_day - , subq_25.metric_time__extract_dow AS metric_time__extract_dow - , subq_25.metric_time__extract_doy AS metric_time__extract_doy - , subq_28.acquired_ds__day AS customer_id__acquired_ds__day - , subq_28.acquired_ds__week AS customer_id__acquired_ds__week - , subq_28.acquired_ds__month AS customer_id__acquired_ds__month - , subq_28.acquired_ds__quarter AS customer_id__acquired_ds__quarter - , subq_28.acquired_ds__year AS customer_id__acquired_ds__year - , subq_28.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year - , subq_28.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter - , subq_28.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month - , subq_28.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day - , subq_28.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow - , subq_28.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy - , subq_28.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day - , subq_28.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week - , subq_28.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month - , subq_28.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter - , subq_28.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year - , subq_28.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year - , subq_28.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter - , subq_28.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month - , subq_28.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day - , subq_28.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow - , subq_28.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy - , subq_28.metric_time__day AS customer_id__metric_time__day - , subq_28.metric_time__week AS customer_id__metric_time__week - , subq_28.metric_time__month AS customer_id__metric_time__month - , subq_28.metric_time__quarter AS customer_id__metric_time__quarter - , subq_28.metric_time__year AS customer_id__metric_time__year - , subq_28.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_28.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_28.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_28.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_28.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_28.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_25.account_id AS account_id - , subq_25.customer_id AS customer_id - , subq_25.account_id__customer_id AS account_id__customer_id - , subq_25.bridge_account__account_id AS bridge_account__account_id - , subq_25.bridge_account__customer_id AS bridge_account__customer_id - , subq_28.customer_third_hop_id AS customer_id__customer_third_hop_id - , subq_28.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id - , subq_25.extra_dim AS extra_dim - , subq_25.account_id__extra_dim AS account_id__extra_dim - , subq_25.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_28.country AS customer_id__country - , subq_28.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country - , subq_25.account_customer_combos AS account_customer_combos + subq_7.ds_partitioned__day AS ds_partitioned__day + , subq_7.ds_partitioned__week AS ds_partitioned__week + , subq_7.ds_partitioned__month AS ds_partitioned__month + , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_7.ds_partitioned__year AS ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_7.metric_time__day AS metric_time__day + , subq_7.metric_time__week AS metric_time__week + , subq_7.metric_time__month AS metric_time__month + , subq_7.metric_time__quarter AS metric_time__quarter + , subq_7.metric_time__year AS metric_time__year + , subq_7.metric_time__extract_year AS metric_time__extract_year + , subq_7.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_7.metric_time__extract_month AS metric_time__extract_month + , subq_7.metric_time__extract_day AS metric_time__extract_day + , subq_7.metric_time__extract_dow AS metric_time__extract_dow + , subq_7.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.acquired_ds__day AS customer_id__acquired_ds__day + , subq_10.acquired_ds__week AS customer_id__acquired_ds__week + , subq_10.acquired_ds__month AS customer_id__acquired_ds__month + , subq_10.acquired_ds__quarter AS customer_id__acquired_ds__quarter + , subq_10.acquired_ds__year AS customer_id__acquired_ds__year + , subq_10.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year + , subq_10.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter + , subq_10.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month + , subq_10.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day + , subq_10.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow + , subq_10.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy + , subq_10.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day + , subq_10.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week + , subq_10.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month + , subq_10.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter + , subq_10.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year + , subq_10.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year + , subq_10.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter + , subq_10.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month + , subq_10.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day + , subq_10.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow + , subq_10.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy + , subq_10.metric_time__day AS customer_id__metric_time__day + , subq_10.metric_time__week AS customer_id__metric_time__week + , subq_10.metric_time__month AS customer_id__metric_time__month + , subq_10.metric_time__quarter AS customer_id__metric_time__quarter + , subq_10.metric_time__year AS customer_id__metric_time__year + , subq_10.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_10.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_10.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_10.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_10.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_10.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_7.account_id AS account_id + , subq_7.customer_id AS customer_id + , subq_7.account_id__customer_id AS account_id__customer_id + , subq_7.bridge_account__account_id AS bridge_account__account_id + , subq_7.bridge_account__customer_id AS bridge_account__customer_id + , subq_10.customer_third_hop_id AS customer_id__customer_third_hop_id + , subq_10.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id + , subq_7.extra_dim AS extra_dim + , subq_7.account_id__extra_dim AS account_id__extra_dim + , subq_7.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_10.country AS customer_id__country + , subq_10.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country + , subq_7.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_24.ds_partitioned__day - , subq_24.ds_partitioned__week - , subq_24.ds_partitioned__month - , subq_24.ds_partitioned__quarter - , subq_24.ds_partitioned__year - , subq_24.ds_partitioned__extract_year - , subq_24.ds_partitioned__extract_quarter - , subq_24.ds_partitioned__extract_month - , subq_24.ds_partitioned__extract_day - , subq_24.ds_partitioned__extract_dow - , subq_24.ds_partitioned__extract_doy - , subq_24.account_id__ds_partitioned__day - , subq_24.account_id__ds_partitioned__week - , subq_24.account_id__ds_partitioned__month - , subq_24.account_id__ds_partitioned__quarter - , subq_24.account_id__ds_partitioned__year - , subq_24.account_id__ds_partitioned__extract_year - , subq_24.account_id__ds_partitioned__extract_quarter - , subq_24.account_id__ds_partitioned__extract_month - , subq_24.account_id__ds_partitioned__extract_day - , subq_24.account_id__ds_partitioned__extract_dow - , subq_24.account_id__ds_partitioned__extract_doy - , subq_24.bridge_account__ds_partitioned__day - , subq_24.bridge_account__ds_partitioned__week - , subq_24.bridge_account__ds_partitioned__month - , subq_24.bridge_account__ds_partitioned__quarter - , subq_24.bridge_account__ds_partitioned__year - , subq_24.bridge_account__ds_partitioned__extract_year - , subq_24.bridge_account__ds_partitioned__extract_quarter - , subq_24.bridge_account__ds_partitioned__extract_month - , subq_24.bridge_account__ds_partitioned__extract_day - , subq_24.bridge_account__ds_partitioned__extract_dow - , subq_24.bridge_account__ds_partitioned__extract_doy - , subq_24.ds_partitioned__day AS metric_time__day - , subq_24.ds_partitioned__week AS metric_time__week - , subq_24.ds_partitioned__month AS metric_time__month - , subq_24.ds_partitioned__quarter AS metric_time__quarter - , subq_24.ds_partitioned__year AS metric_time__year - , subq_24.ds_partitioned__extract_year AS metric_time__extract_year - , subq_24.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_24.ds_partitioned__extract_month AS metric_time__extract_month - , subq_24.ds_partitioned__extract_day AS metric_time__extract_day - , subq_24.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_24.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_24.account_id - , subq_24.customer_id - , subq_24.account_id__customer_id - , subq_24.bridge_account__account_id - , subq_24.bridge_account__customer_id - , subq_24.extra_dim - , subq_24.account_id__extra_dim - , subq_24.bridge_account__extra_dim - , subq_24.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_6.account_id__ds_partitioned__week + , subq_6.account_id__ds_partitioned__month + , subq_6.account_id__ds_partitioned__quarter + , subq_6.account_id__ds_partitioned__year + , subq_6.account_id__ds_partitioned__extract_year + , subq_6.account_id__ds_partitioned__extract_quarter + , subq_6.account_id__ds_partitioned__extract_month + , subq_6.account_id__ds_partitioned__extract_day + , subq_6.account_id__ds_partitioned__extract_dow + , subq_6.account_id__ds_partitioned__extract_doy + , subq_6.bridge_account__ds_partitioned__day + , subq_6.bridge_account__ds_partitioned__week + , subq_6.bridge_account__ds_partitioned__month + , subq_6.bridge_account__ds_partitioned__quarter + , subq_6.bridge_account__ds_partitioned__year + , subq_6.bridge_account__ds_partitioned__extract_year + , subq_6.bridge_account__ds_partitioned__extract_quarter + , subq_6.bridge_account__ds_partitioned__extract_month + , subq_6.bridge_account__ds_partitioned__extract_day + , subq_6.bridge_account__ds_partitioned__extract_dow + , subq_6.bridge_account__ds_partitioned__extract_doy + , subq_6.ds_partitioned__day AS metric_time__day + , subq_6.ds_partitioned__week AS metric_time__week + , subq_6.ds_partitioned__month AS metric_time__month + , subq_6.ds_partitioned__quarter AS metric_time__quarter + , subq_6.ds_partitioned__year AS metric_time__year + , subq_6.ds_partitioned__extract_year AS metric_time__extract_year + , subq_6.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_6.ds_partitioned__extract_month AS metric_time__extract_month + , subq_6.ds_partitioned__extract_day AS metric_time__extract_day + , subq_6.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_6.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_6.account_id + , subq_6.customer_id + , subq_6.account_id__customer_id + , subq_6.bridge_account__account_id + , subq_6.bridge_account__customer_id + , subq_6.extra_dim + , subq_6.account_id__extra_dim + , subq_6.bridge_account__extra_dim + , subq_6.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -456,8 +456,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_24 - ) subq_25 + ) subq_6 + ) subq_7 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'country', @@ -513,112 +513,112 @@ FROM ( -- 'customer_third_hop_id__customer_id', -- ] SELECT - subq_27.acquired_ds__day - , subq_27.acquired_ds__week - , subq_27.acquired_ds__month - , subq_27.acquired_ds__quarter - , subq_27.acquired_ds__year - , subq_27.acquired_ds__extract_year - , subq_27.acquired_ds__extract_quarter - , subq_27.acquired_ds__extract_month - , subq_27.acquired_ds__extract_day - , subq_27.acquired_ds__extract_dow - , subq_27.acquired_ds__extract_doy - , subq_27.customer_id__acquired_ds__day - , subq_27.customer_id__acquired_ds__week - , subq_27.customer_id__acquired_ds__month - , subq_27.customer_id__acquired_ds__quarter - , subq_27.customer_id__acquired_ds__year - , subq_27.customer_id__acquired_ds__extract_year - , subq_27.customer_id__acquired_ds__extract_quarter - , subq_27.customer_id__acquired_ds__extract_month - , subq_27.customer_id__acquired_ds__extract_day - , subq_27.customer_id__acquired_ds__extract_dow - , subq_27.customer_id__acquired_ds__extract_doy - , subq_27.customer_third_hop_id__acquired_ds__day - , subq_27.customer_third_hop_id__acquired_ds__week - , subq_27.customer_third_hop_id__acquired_ds__month - , subq_27.customer_third_hop_id__acquired_ds__quarter - , subq_27.customer_third_hop_id__acquired_ds__year - , subq_27.customer_third_hop_id__acquired_ds__extract_year - , subq_27.customer_third_hop_id__acquired_ds__extract_quarter - , subq_27.customer_third_hop_id__acquired_ds__extract_month - , subq_27.customer_third_hop_id__acquired_ds__extract_day - , subq_27.customer_third_hop_id__acquired_ds__extract_dow - , subq_27.customer_third_hop_id__acquired_ds__extract_doy - , subq_27.metric_time__day - , subq_27.metric_time__week - , subq_27.metric_time__month - , subq_27.metric_time__quarter - , subq_27.metric_time__year - , subq_27.metric_time__extract_year - , subq_27.metric_time__extract_quarter - , subq_27.metric_time__extract_month - , subq_27.metric_time__extract_day - , subq_27.metric_time__extract_dow - , subq_27.metric_time__extract_doy - , subq_27.customer_id - , subq_27.customer_third_hop_id - , subq_27.customer_id__customer_third_hop_id - , subq_27.customer_third_hop_id__customer_id - , subq_27.country - , subq_27.customer_id__country - , subq_27.customer_third_hop_id__country + subq_9.acquired_ds__day + , subq_9.acquired_ds__week + , subq_9.acquired_ds__month + , subq_9.acquired_ds__quarter + , subq_9.acquired_ds__year + , subq_9.acquired_ds__extract_year + , subq_9.acquired_ds__extract_quarter + , subq_9.acquired_ds__extract_month + , subq_9.acquired_ds__extract_day + , subq_9.acquired_ds__extract_dow + , subq_9.acquired_ds__extract_doy + , subq_9.customer_id__acquired_ds__day + , subq_9.customer_id__acquired_ds__week + , subq_9.customer_id__acquired_ds__month + , subq_9.customer_id__acquired_ds__quarter + , subq_9.customer_id__acquired_ds__year + , subq_9.customer_id__acquired_ds__extract_year + , subq_9.customer_id__acquired_ds__extract_quarter + , subq_9.customer_id__acquired_ds__extract_month + , subq_9.customer_id__acquired_ds__extract_day + , subq_9.customer_id__acquired_ds__extract_dow + , subq_9.customer_id__acquired_ds__extract_doy + , subq_9.customer_third_hop_id__acquired_ds__day + , subq_9.customer_third_hop_id__acquired_ds__week + , subq_9.customer_third_hop_id__acquired_ds__month + , subq_9.customer_third_hop_id__acquired_ds__quarter + , subq_9.customer_third_hop_id__acquired_ds__year + , subq_9.customer_third_hop_id__acquired_ds__extract_year + , subq_9.customer_third_hop_id__acquired_ds__extract_quarter + , subq_9.customer_third_hop_id__acquired_ds__extract_month + , subq_9.customer_third_hop_id__acquired_ds__extract_day + , subq_9.customer_third_hop_id__acquired_ds__extract_dow + , subq_9.customer_third_hop_id__acquired_ds__extract_doy + , subq_9.metric_time__day + , subq_9.metric_time__week + , subq_9.metric_time__month + , subq_9.metric_time__quarter + , subq_9.metric_time__year + , subq_9.metric_time__extract_year + , subq_9.metric_time__extract_quarter + , subq_9.metric_time__extract_month + , subq_9.metric_time__extract_day + , subq_9.metric_time__extract_dow + , subq_9.metric_time__extract_doy + , subq_9.customer_id + , subq_9.customer_third_hop_id + , subq_9.customer_id__customer_third_hop_id + , subq_9.customer_third_hop_id__customer_id + , subq_9.country + , subq_9.customer_id__country + , subq_9.customer_third_hop_id__country FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - subq_26.acquired_ds__day - , subq_26.acquired_ds__week - , subq_26.acquired_ds__month - , subq_26.acquired_ds__quarter - , subq_26.acquired_ds__year - , subq_26.acquired_ds__extract_year - , subq_26.acquired_ds__extract_quarter - , subq_26.acquired_ds__extract_month - , subq_26.acquired_ds__extract_day - , subq_26.acquired_ds__extract_dow - , subq_26.acquired_ds__extract_doy - , subq_26.customer_id__acquired_ds__day - , subq_26.customer_id__acquired_ds__week - , subq_26.customer_id__acquired_ds__month - , subq_26.customer_id__acquired_ds__quarter - , subq_26.customer_id__acquired_ds__year - , subq_26.customer_id__acquired_ds__extract_year - , subq_26.customer_id__acquired_ds__extract_quarter - , subq_26.customer_id__acquired_ds__extract_month - , subq_26.customer_id__acquired_ds__extract_day - , subq_26.customer_id__acquired_ds__extract_dow - , subq_26.customer_id__acquired_ds__extract_doy - , subq_26.customer_third_hop_id__acquired_ds__day - , subq_26.customer_third_hop_id__acquired_ds__week - , subq_26.customer_third_hop_id__acquired_ds__month - , subq_26.customer_third_hop_id__acquired_ds__quarter - , subq_26.customer_third_hop_id__acquired_ds__year - , subq_26.customer_third_hop_id__acquired_ds__extract_year - , subq_26.customer_third_hop_id__acquired_ds__extract_quarter - , subq_26.customer_third_hop_id__acquired_ds__extract_month - , subq_26.customer_third_hop_id__acquired_ds__extract_day - , subq_26.customer_third_hop_id__acquired_ds__extract_dow - , subq_26.customer_third_hop_id__acquired_ds__extract_doy - , subq_26.acquired_ds__day AS metric_time__day - , subq_26.acquired_ds__week AS metric_time__week - , subq_26.acquired_ds__month AS metric_time__month - , subq_26.acquired_ds__quarter AS metric_time__quarter - , subq_26.acquired_ds__year AS metric_time__year - , subq_26.acquired_ds__extract_year AS metric_time__extract_year - , subq_26.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_26.acquired_ds__extract_month AS metric_time__extract_month - , subq_26.acquired_ds__extract_day AS metric_time__extract_day - , subq_26.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_26.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_26.customer_id - , subq_26.customer_third_hop_id - , subq_26.customer_id__customer_third_hop_id - , subq_26.customer_third_hop_id__customer_id - , subq_26.country - , subq_26.customer_id__country - , subq_26.customer_third_hop_id__country - , subq_26.customers_with_other_data + subq_8.acquired_ds__day + , subq_8.acquired_ds__week + , subq_8.acquired_ds__month + , subq_8.acquired_ds__quarter + , subq_8.acquired_ds__year + , subq_8.acquired_ds__extract_year + , subq_8.acquired_ds__extract_quarter + , subq_8.acquired_ds__extract_month + , subq_8.acquired_ds__extract_day + , subq_8.acquired_ds__extract_dow + , subq_8.acquired_ds__extract_doy + , subq_8.customer_id__acquired_ds__day + , subq_8.customer_id__acquired_ds__week + , subq_8.customer_id__acquired_ds__month + , subq_8.customer_id__acquired_ds__quarter + , subq_8.customer_id__acquired_ds__year + , subq_8.customer_id__acquired_ds__extract_year + , subq_8.customer_id__acquired_ds__extract_quarter + , subq_8.customer_id__acquired_ds__extract_month + , subq_8.customer_id__acquired_ds__extract_day + , subq_8.customer_id__acquired_ds__extract_dow + , subq_8.customer_id__acquired_ds__extract_doy + , subq_8.customer_third_hop_id__acquired_ds__day + , subq_8.customer_third_hop_id__acquired_ds__week + , subq_8.customer_third_hop_id__acquired_ds__month + , subq_8.customer_third_hop_id__acquired_ds__quarter + , subq_8.customer_third_hop_id__acquired_ds__year + , subq_8.customer_third_hop_id__acquired_ds__extract_year + , subq_8.customer_third_hop_id__acquired_ds__extract_quarter + , subq_8.customer_third_hop_id__acquired_ds__extract_month + , subq_8.customer_third_hop_id__acquired_ds__extract_day + , subq_8.customer_third_hop_id__acquired_ds__extract_dow + , subq_8.customer_third_hop_id__acquired_ds__extract_doy + , subq_8.acquired_ds__day AS metric_time__day + , subq_8.acquired_ds__week AS metric_time__week + , subq_8.acquired_ds__month AS metric_time__month + , subq_8.acquired_ds__quarter AS metric_time__quarter + , subq_8.acquired_ds__year AS metric_time__year + , subq_8.acquired_ds__extract_year AS metric_time__extract_year + , subq_8.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_8.acquired_ds__extract_month AS metric_time__extract_month + , subq_8.acquired_ds__extract_day AS metric_time__extract_day + , subq_8.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_8.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_8.customer_id + , subq_8.customer_third_hop_id + , subq_8.customer_id__customer_third_hop_id + , subq_8.customer_third_hop_id__customer_id + , subq_8.country + , subq_8.customer_id__country + , subq_8.customer_third_hop_id__country + , subq_8.customers_with_other_data FROM ( -- Read Elements From Semantic Model 'customer_other_data' SELECT @@ -664,31 +664,31 @@ 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_26 - ) subq_27 - ) subq_28 + ) subq_8 + ) subq_9 + ) subq_10 ON - subq_25.customer_id = subq_28.customer_id - ) subq_29 - ) subq_30 + subq_7.customer_id = subq_10.customer_id + ) subq_11 + ) subq_12 ON ( - subq_23.account_id = subq_30.account_id + subq_5.account_id = subq_12.account_id ) AND ( - subq_23.ds_partitioned__day = subq_30.ds_partitioned__day + subq_5.ds_partitioned__day = subq_12.ds_partitioned__day ) - ) subq_31 - ) subq_32 + ) subq_13 + ) subq_14 GROUP BY - subq_32.account_id__customer_id__customer_third_hop_id - ) subq_33 - ) subq_34 - ) subq_35 + subq_14.account_id__customer_id__customer_third_hop_id + ) subq_15 + ) subq_16 + ) subq_17 ON - subq_20.customer_third_hop_id = subq_35.account_id__customer_id__customer_third_hop_id - ) subq_36 - ) subq_37 + subq_2.customer_third_hop_id = subq_17.account_id__customer_id__customer_third_hop_id + ) subq_18 + ) subq_19 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 - ) subq_38 - ) subq_39 -) subq_40 + ) subq_20 + ) subq_21 +) subq_22 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_multi_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_multi_hop__plan0_optimized.sql index bf66de5356..97117da92a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_multi_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_multi_hop__plan0_optimized.sql @@ -8,7 +8,7 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_76.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + subq_40.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count , 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 ( @@ -18,7 +18,7 @@ FROM ( -- Compute Metrics via Expressions -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_71.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + subq_35.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id , SUM(account_month_txns_src_22000.txn_count) AS account_id__customer_id__customer_third_hop_id__txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -33,17 +33,17 @@ FROM ( ***************************.customer_other_data customer_other_data_src_22000 ON bridge_table_src_22000.customer_id = customer_other_data_src_22000.customer_id - ) subq_71 + ) subq_35 ON ( - account_month_txns_src_22000.account_id = subq_71.account_id + account_month_txns_src_22000.account_id = subq_35.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_71.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_35.ds_partitioned__day ) GROUP BY - subq_71.customer_id__customer_third_hop_id - ) subq_76 + subq_35.customer_id__customer_third_hop_id + ) subq_40 ON - third_hop_table_src_22000.customer_third_hop_id = subq_76.account_id__customer_id__customer_third_hop_id -) subq_78 + third_hop_table_src_22000.customer_third_hop_id = subq_40.account_id__customer_id__customer_third_hop_id +) subq_42 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_single_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_single_hop__plan0.sql index 5938f67a2e..08e18257d9 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_single_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_single_hop__plan0.sql @@ -1,76 +1,76 @@ -- Compute Metrics via Expressions SELECT - subq_25.third_hop_count + subq_16.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_24.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_15.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_23.third_hop_count + subq_14.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_22.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_22.third_hop_count + subq_13.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_13.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_21.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_21.third_hop_count + subq_12.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_12.third_hop_count FROM ( -- Join Standard Outputs SELECT - 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 + subq_2.customer_third_hop_id AS customer_third_hop_id + , subq_11.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_11.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_2.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_10.customer_third_hop_id - , subq_10.third_hop_count + subq_1.customer_third_hop_id + , subq_1.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - 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 + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.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_9 - ) subq_10 - ) subq_11 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_19.customer_id__customer_third_hop_id - , subq_19.customer_id__customer_third_hop_id__paraguayan_customers + subq_10.customer_id__customer_third_hop_id + , subq_10.customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Compute Metrics via Expressions SELECT - subq_18.customer_id__customer_third_hop_id - , subq_18.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_9.customer_id__customer_third_hop_id + , subq_9.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Aggregate Measures SELECT - subq_17.customer_id__customer_third_hop_id - , SUM(subq_17.customers_with_other_data) AS customers_with_other_data + subq_8.customer_id__customer_third_hop_id + , SUM(subq_8.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_16.customer_id__customer_third_hop_id - , subq_16.customers_with_other_data + subq_7.customer_id__customer_third_hop_id + , subq_7.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_15.customer_id__customer_third_hop_id - , subq_15.customer_id__country - , subq_15.customers_with_other_data + subq_6.customer_id__customer_third_hop_id + , subq_6.customer_id__country + , subq_6.customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT - subq_14.customer_id__customer_third_hop_id - , subq_14.customer_id__country - , subq_14.customers_with_other_data + subq_5.customer_id__customer_third_hop_id + , subq_5.customer_id__country + , subq_5.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - 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 + subq_4.acquired_ds__day + , subq_4.acquired_ds__week + , subq_4.acquired_ds__month + , subq_4.acquired_ds__quarter + , subq_4.acquired_ds__year + , subq_4.acquired_ds__extract_year + , subq_4.acquired_ds__extract_quarter + , subq_4.acquired_ds__extract_month + , subq_4.acquired_ds__extract_day + , subq_4.acquired_ds__extract_dow + , subq_4.acquired_ds__extract_doy + , subq_4.customer_id__acquired_ds__day + , subq_4.customer_id__acquired_ds__week + , subq_4.customer_id__acquired_ds__month + , subq_4.customer_id__acquired_ds__quarter + , subq_4.customer_id__acquired_ds__year + , subq_4.customer_id__acquired_ds__extract_year + , subq_4.customer_id__acquired_ds__extract_quarter + , subq_4.customer_id__acquired_ds__extract_month + , subq_4.customer_id__acquired_ds__extract_day + , subq_4.customer_id__acquired_ds__extract_dow + , subq_4.customer_id__acquired_ds__extract_doy + , subq_4.customer_third_hop_id__acquired_ds__day + , subq_4.customer_third_hop_id__acquired_ds__week + , subq_4.customer_third_hop_id__acquired_ds__month + , subq_4.customer_third_hop_id__acquired_ds__quarter + , subq_4.customer_third_hop_id__acquired_ds__year + , subq_4.customer_third_hop_id__acquired_ds__extract_year + , subq_4.customer_third_hop_id__acquired_ds__extract_quarter + , subq_4.customer_third_hop_id__acquired_ds__extract_month + , subq_4.customer_third_hop_id__acquired_ds__extract_day + , subq_4.customer_third_hop_id__acquired_ds__extract_dow + , subq_4.customer_third_hop_id__acquired_ds__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.customer_id + , subq_4.customer_third_hop_id + , subq_4.customer_id__customer_third_hop_id + , subq_4.customer_third_hop_id__customer_id + , subq_4.country + , subq_4.customer_id__country + , subq_4.customer_third_hop_id__country + , subq_4.customers_with_other_data FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - 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 + subq_3.acquired_ds__day + , subq_3.acquired_ds__week + , subq_3.acquired_ds__month + , subq_3.acquired_ds__quarter + , subq_3.acquired_ds__year + , subq_3.acquired_ds__extract_year + , subq_3.acquired_ds__extract_quarter + , subq_3.acquired_ds__extract_month + , subq_3.acquired_ds__extract_day + , subq_3.acquired_ds__extract_dow + , subq_3.acquired_ds__extract_doy + , subq_3.customer_id__acquired_ds__day + , subq_3.customer_id__acquired_ds__week + , subq_3.customer_id__acquired_ds__month + , subq_3.customer_id__acquired_ds__quarter + , subq_3.customer_id__acquired_ds__year + , subq_3.customer_id__acquired_ds__extract_year + , subq_3.customer_id__acquired_ds__extract_quarter + , subq_3.customer_id__acquired_ds__extract_month + , subq_3.customer_id__acquired_ds__extract_day + , subq_3.customer_id__acquired_ds__extract_dow + , subq_3.customer_id__acquired_ds__extract_doy + , subq_3.customer_third_hop_id__acquired_ds__day + , subq_3.customer_third_hop_id__acquired_ds__week + , subq_3.customer_third_hop_id__acquired_ds__month + , subq_3.customer_third_hop_id__acquired_ds__quarter + , subq_3.customer_third_hop_id__acquired_ds__year + , subq_3.customer_third_hop_id__acquired_ds__extract_year + , subq_3.customer_third_hop_id__acquired_ds__extract_quarter + , subq_3.customer_third_hop_id__acquired_ds__extract_month + , subq_3.customer_third_hop_id__acquired_ds__extract_day + , subq_3.customer_third_hop_id__acquired_ds__extract_dow + , subq_3.customer_third_hop_id__acquired_ds__extract_doy + , subq_3.acquired_ds__day AS metric_time__day + , subq_3.acquired_ds__week AS metric_time__week + , subq_3.acquired_ds__month AS metric_time__month + , subq_3.acquired_ds__quarter AS metric_time__quarter + , subq_3.acquired_ds__year AS metric_time__year + , subq_3.acquired_ds__extract_year AS metric_time__extract_year + , subq_3.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_3.acquired_ds__extract_month AS metric_time__extract_month + , subq_3.acquired_ds__extract_day AS metric_time__extract_day + , subq_3.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_3.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_3.customer_id + , subq_3.customer_third_hop_id + , subq_3.customer_id__customer_third_hop_id + , subq_3.customer_third_hop_id__customer_id + , subq_3.country + , subq_3.customer_id__country + , subq_3.customer_third_hop_id__country + , subq_3.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_12 - ) subq_13 + ) subq_3 + ) subq_4 WHERE customer_id__country = 'paraguay' - ) subq_14 - ) subq_15 + ) subq_5 + ) subq_6 WHERE customer_id__country = 'paraguay' - ) subq_16 - ) subq_17 + ) subq_7 + ) subq_8 GROUP BY - subq_17.customer_id__customer_third_hop_id - ) subq_18 - ) subq_19 - ) subq_20 + subq_8.customer_id__customer_third_hop_id + ) subq_9 + ) subq_10 + ) subq_11 ON - subq_11.customer_third_hop_id = subq_20.customer_id__customer_third_hop_id - ) subq_21 - ) subq_22 + subq_2.customer_third_hop_id = subq_11.customer_id__customer_third_hop_id + ) subq_12 + ) subq_13 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_23 - ) subq_24 -) subq_25 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_single_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_single_hop__plan0_optimized.sql index 0fd2bf1820..b73c99c9a9 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_single_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/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_46.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_28.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_39 + ) subq_21 WHERE customer_id__country = 'paraguay' - ) subq_41 + ) subq_23 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_46 + ) subq_28 ON - third_hop_table_src_22000.customer_third_hop_id = subq_46.customer_id__customer_third_hop_id -) subq_48 + third_hop_table_src_22000.customer_third_hop_id = subq_28.customer_id__customer_third_hop_id +) subq_30 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_filtered_by_itself__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_filtered_by_itself__plan0.sql index 8214758700..d0dc709959 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_filtered_by_itself__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_filtered_by_itself__plan0.sql @@ -1,136 +1,136 @@ -- Compute Metrics via Expressions SELECT - subq_17.bookers + subq_13.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_16.bookers) AS bookers + COUNT(DISTINCT subq_12.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_15.bookers + subq_11.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_14.listing__bookers - , subq_14.bookers + subq_10.listing__bookers + , subq_10.bookers FROM ( -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_13.listing__bookers - , subq_13.bookers + subq_9.listing__bookers + , subq_9.bookers FROM ( -- Join Standard Outputs SELECT - subq_6.listing AS listing - , subq_12.listing__bookers AS listing__bookers - , subq_6.bookers AS bookers + subq_2.listing AS listing + , subq_8.listing__bookers AS listing__bookers + , subq_2.bookers AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_5.listing - , subq_5.bookers + subq_1.listing + , subq_1.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -223,130 +223,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookers'] SELECT - subq_11.listing - , subq_11.listing__bookers + subq_7.listing + , subq_7.listing__bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookers AS listing__bookers + subq_6.listing + , subq_6.bookers AS listing__bookers FROM ( -- Aggregate Measures SELECT - subq_9.listing - , COUNT(DISTINCT subq_9.bookers) AS bookers + subq_5.listing + , COUNT(DISTINCT subq_5.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_8.listing - , subq_8.bookers + subq_4.listing + , subq_4.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -439,19 +439,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.listing - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookers > 1.00 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_filtered_by_itself__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_filtered_by_itself__plan0_optimized.sql index e5c7db19a1..fc6f75f09e 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_filtered_by_itself__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_filtered_by_itself__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_30.listing__bookers AS listing__bookers - , subq_24.bookers AS bookers + subq_22.listing__bookers AS listing__bookers + , subq_16.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookers > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_with_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_with_metric_in_where_filter__plan0.sql index cf6fce632c..2af39223a4 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_with_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_with_metric_in_where_filter__plan0.sql @@ -1,112 +1,112 @@ -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day - , subq_17.listings AS active_listings + subq_13.metric_time__day + , subq_13.listings AS active_listings FROM ( -- Aggregate Measures SELECT - subq_16.metric_time__day - , SUM(subq_16.listings) AS listings + subq_12.metric_time__day + , SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day'] SELECT - subq_15.metric_time__day - , subq_15.listings + subq_11.metric_time__day + , subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.metric_time__day - , subq_14.listing__bookings - , subq_14.listings + subq_10.metric_time__day + , subq_10.listing__bookings + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_13.metric_time__day - , subq_13.listing__bookings - , subq_13.listings + subq_9.metric_time__day + , subq_9.listing__bookings + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.metric_time__day AS metric_time__day - , subq_6.listing AS listing - , subq_12.listing__bookings AS listing__bookings - , subq_6.listings AS listings + subq_2.metric_time__day AS metric_time__day + , subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] SELECT - subq_5.metric_time__day - , subq_5.listing - , subq_5.listings + subq_1.metric_time__day + , subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -167,130 +167,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_11.listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing - , SUM(subq_9.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_8.listing - , subq_8.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -383,21 +383,21 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.listing - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookings > 2 - ) subq_15 - ) subq_16 + ) subq_11 + ) subq_12 GROUP BY - subq_16.metric_time__day -) subq_17 + subq_12.metric_time__day +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_with_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_with_metric_in_where_filter__plan0_optimized.sql index a43cba6c94..21fd1f7db3 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_with_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_with_metric_in_where_filter__plan0_optimized.sql @@ -9,9 +9,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_24.metric_time__day AS metric_time__day - , subq_30.listing__bookings AS listing__bookings - , subq_24.listings AS listings + subq_16.metric_time__day AS metric_time__day + , subq_22.listing__bookings AS listing__bookings + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -21,7 +21,7 @@ FROM ( , listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -37,13 +37,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_27 + ) subq_19 GROUP BY listing - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookings > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_cumulative_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_cumulative_metric_in_where_filter__plan0.sql index dc55a381b5..60cff44870 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_cumulative_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_cumulative_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_17.listings + subq_13.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_16.listings) AS listings + SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_15.listings + subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.user__revenue_all_time - , subq_14.listings + subq_10.user__revenue_all_time + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_13.user__revenue_all_time - , subq_13.listings + subq_9.user__revenue_all_time + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.user AS user - , subq_12.user__revenue_all_time AS user__revenue_all_time - , subq_6.listings AS listings + subq_2.user AS user + , subq_8.user__revenue_all_time AS user__revenue_all_time + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'user'] SELECT - subq_5.user - , subq_5.listings + subq_1.user + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,68 +160,68 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user', 'user__revenue_all_time'] SELECT - subq_11.user - , subq_11.user__revenue_all_time + subq_7.user + , subq_7.user__revenue_all_time FROM ( -- Compute Metrics via Expressions SELECT - subq_10.user - , subq_10.txn_revenue AS user__revenue_all_time + subq_6.user + , subq_6.txn_revenue AS user__revenue_all_time FROM ( -- Aggregate Measures SELECT - subq_9.user - , SUM(subq_9.txn_revenue) AS txn_revenue + subq_5.user + , SUM(subq_5.txn_revenue) AS txn_revenue FROM ( -- Pass Only Elements: ['txn_revenue', 'user'] SELECT - subq_8.user - , subq_8.txn_revenue + subq_4.user + , subq_4.txn_revenue FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.revenue_instance__ds__day - , subq_7.revenue_instance__ds__week - , subq_7.revenue_instance__ds__month - , subq_7.revenue_instance__ds__quarter - , subq_7.revenue_instance__ds__year - , subq_7.revenue_instance__ds__extract_year - , subq_7.revenue_instance__ds__extract_quarter - , subq_7.revenue_instance__ds__extract_month - , subq_7.revenue_instance__ds__extract_day - , subq_7.revenue_instance__ds__extract_dow - , subq_7.revenue_instance__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.revenue_instance__user - , subq_7.txn_revenue + 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.revenue_instance__ds__day + , subq_3.revenue_instance__ds__week + , subq_3.revenue_instance__ds__month + , subq_3.revenue_instance__ds__quarter + , subq_3.revenue_instance__ds__year + , subq_3.revenue_instance__ds__extract_year + , subq_3.revenue_instance__ds__extract_quarter + , subq_3.revenue_instance__ds__extract_month + , subq_3.revenue_instance__ds__extract_day + , subq_3.revenue_instance__ds__extract_dow + , subq_3.revenue_instance__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_3.user + , subq_3.revenue_instance__user + , subq_3.txn_revenue FROM ( -- Read Elements From Semantic Model 'revenue' SELECT @@ -251,19 +251,19 @@ FROM ( , revenue_src_28000.user_id AS user , revenue_src_28000.user_id AS revenue_instance__user FROM ***************************.fct_revenue revenue_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.user - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.user + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.user = subq_12.user - ) subq_13 - ) subq_14 + subq_2.user = subq_8.user + ) subq_9 + ) subq_10 WHERE user__revenue_all_time > 1 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql index 4f006f13ed..2b782589e8 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_30.user__revenue_all_time AS user__revenue_all_time - , subq_24.listings AS listings + subq_22.user__revenue_all_time AS user__revenue_all_time + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -32,8 +32,8 @@ FROM ( FROM ***************************.fct_revenue revenue_src_28000 GROUP BY user_id - ) subq_30 + ) subq_22 ON - subq_24.user = subq_30.user -) subq_32 + subq_16.user = subq_22.user +) subq_24 WHERE user__revenue_all_time > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_derived_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_derived_metric_in_where_filter__plan0.sql index e054300a84..d293da2f40 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_derived_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_derived_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_31.listings + subq_20.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_30.listings) AS listings + SUM(subq_19.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_29.listings + subq_18.listings FROM ( -- Constrain Output with WHERE SELECT - subq_28.listing__views_times_booking_value - , subq_28.listings + subq_17.listing__views_times_booking_value + , subq_17.listings FROM ( -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_27.listing__views_times_booking_value - , subq_27.listings + subq_16.listing__views_times_booking_value + , subq_16.listings FROM ( -- Join Standard Outputs SELECT - subq_13.listing AS listing - , subq_26.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_13.listings AS listings + subq_2.listing AS listing + , subq_15.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_12.listing - , subq_12.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,141 +160,141 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] SELECT - subq_25.listing - , subq_25.listing__views_times_booking_value + subq_14.listing + , subq_14.listing__views_times_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_24.listing + subq_13.listing , booking_value * views AS listing__views_times_booking_value FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.listing, subq_23.listing) AS listing - , MAX(subq_18.booking_value) AS booking_value - , MAX(subq_23.views) AS views + COALESCE(subq_7.listing, subq_12.listing) AS listing + , MAX(subq_7.booking_value) AS booking_value + , MAX(subq_12.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_17.listing - , subq_17.booking_value + subq_6.listing + , subq_6.booking_value FROM ( -- Aggregate Measures SELECT - subq_16.listing - , SUM(subq_16.booking_value) AS booking_value + subq_5.listing + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'listing'] SELECT - subq_15.listing - , subq_15.booking_value + subq_4.listing + , subq_4.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_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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -387,91 +387,91 @@ 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_3 + ) subq_4 + ) subq_5 GROUP BY - subq_16.listing - ) subq_17 - ) subq_18 + subq_5.listing + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.listing - , subq_22.views + subq_11.listing + , subq_11.views FROM ( -- Aggregate Measures SELECT - subq_21.listing - , SUM(subq_21.views) AS views + subq_10.listing + , SUM(subq_10.views) AS views FROM ( -- Pass Only Elements: ['views', 'listing'] SELECT - subq_20.listing - , subq_20.views + subq_9.listing + , subq_9.views FROM ( -- Metric Time Dimension 'ds' 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.view__ds__day - , subq_19.view__ds__week - , subq_19.view__ds__month - , subq_19.view__ds__quarter - , subq_19.view__ds__year - , subq_19.view__ds__extract_year - , subq_19.view__ds__extract_quarter - , subq_19.view__ds__extract_month - , subq_19.view__ds__extract_day - , subq_19.view__ds__extract_dow - , subq_19.view__ds__extract_doy - , subq_19.view__ds_partitioned__day - , subq_19.view__ds_partitioned__week - , subq_19.view__ds_partitioned__month - , subq_19.view__ds_partitioned__quarter - , subq_19.view__ds_partitioned__year - , subq_19.view__ds_partitioned__extract_year - , subq_19.view__ds_partitioned__extract_quarter - , subq_19.view__ds_partitioned__extract_month - , subq_19.view__ds_partitioned__extract_day - , subq_19.view__ds_partitioned__extract_dow - , subq_19.view__ds_partitioned__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.user - , subq_19.view__listing - , subq_19.view__user - , subq_19.views + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.view__ds__day + , subq_8.view__ds__week + , subq_8.view__ds__month + , subq_8.view__ds__quarter + , subq_8.view__ds__year + , subq_8.view__ds__extract_year + , subq_8.view__ds__extract_quarter + , subq_8.view__ds__extract_month + , subq_8.view__ds__extract_day + , subq_8.view__ds__extract_dow + , subq_8.view__ds__extract_doy + , subq_8.view__ds_partitioned__day + , subq_8.view__ds_partitioned__week + , subq_8.view__ds_partitioned__month + , subq_8.view__ds_partitioned__quarter + , subq_8.view__ds_partitioned__year + , subq_8.view__ds_partitioned__extract_year + , subq_8.view__ds_partitioned__extract_quarter + , subq_8.view__ds_partitioned__extract_month + , subq_8.view__ds_partitioned__extract_day + , subq_8.view__ds_partitioned__extract_dow + , subq_8.view__ds_partitioned__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.user + , subq_8.view__listing + , subq_8.view__user + , subq_8.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT @@ -525,25 +525,25 @@ FROM ( , views_source_src_28000.listing_id AS view__listing , views_source_src_28000.user_id AS view__user FROM ***************************.fct_views views_source_src_28000 - ) subq_19 - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_21.listing - ) subq_22 - ) subq_23 + subq_10.listing + ) subq_11 + ) subq_12 ON - subq_18.listing = subq_23.listing + subq_7.listing = subq_12.listing GROUP BY - COALESCE(subq_18.listing, subq_23.listing) - ) subq_24 - ) subq_25 - ) subq_26 + COALESCE(subq_7.listing, subq_12.listing) + ) subq_13 + ) subq_14 + ) subq_15 ON - subq_13.listing = subq_26.listing - ) subq_27 - ) subq_28 + subq_2.listing = subq_15.listing + ) subq_16 + ) subq_17 WHERE listing__views_times_booking_value > 1 - ) subq_29 - ) subq_30 -) subq_31 + ) subq_18 + ) subq_19 +) subq_20 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql index f8024b63f1..e5f6bf61fb 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_58.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_45.listings AS listings + subq_36.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_23.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_45 + ) subq_23 LEFT OUTER JOIN ( -- Compute Metrics via Expressions -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] @@ -28,9 +28,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_50.listing, subq_55.listing) AS listing - , MAX(subq_50.booking_value) AS booking_value - , MAX(subq_55.views) AS views + COALESCE(subq_28.listing, subq_33.listing) AS listing + , MAX(subq_28.booking_value) AS booking_value + , MAX(subq_33.views) AS views FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -43,7 +43,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_50 + ) subq_28 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -58,17 +58,17 @@ FROM ( listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_53 + ) subq_31 GROUP BY listing - ) subq_55 + ) subq_33 ON - subq_50.listing = subq_55.listing + subq_28.listing = subq_33.listing GROUP BY - COALESCE(subq_50.listing, subq_55.listing) - ) subq_56 - ) subq_58 + COALESCE(subq_28.listing, subq_33.listing) + ) subq_34 + ) subq_36 ON - subq_45.listing = subq_58.listing -) subq_60 + subq_23.listing = subq_36.listing +) subq_38 WHERE listing__views_times_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_multiple_metrics_in_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_multiple_metrics_in_filter__plan0.sql index b778242996..c7e55c7f64 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_multiple_metrics_in_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_multiple_metrics_in_filter__plan0.sql @@ -1,108 +1,108 @@ -- Compute Metrics via Expressions SELECT - subq_27.listings + subq_19.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_26.listings) AS listings + SUM(subq_18.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_25.listings + subq_17.listings FROM ( -- Constrain Output with WHERE SELECT - subq_24.listing__bookings - , subq_24.listing__bookers - , subq_24.listings + subq_16.listing__bookings + , subq_16.listing__bookers + , subq_16.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_23.listing__bookings - , subq_23.listing__bookers - , subq_23.listings + subq_15.listing__bookings + , subq_15.listing__bookers + , subq_15.listings FROM ( -- Join Standard Outputs SELECT - subq_10.listing AS listing - , subq_16.listing__bookings AS listing__bookings - , subq_22.listing__bookers AS listing__bookers - , subq_10.listings AS listings + subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_14.listing__bookers AS listing__bookers + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing', 'listing'] SELECT - subq_9.listing - , subq_9.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' 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.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , 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.listings - , subq_8.largest_listing - , subq_8.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -163,130 +163,130 @@ 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_8 - ) subq_9 - ) subq_10 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_15.listing - , subq_15.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_13.listing - , SUM(subq_13.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_12.listing - , subq_12.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.paid_at__day - , subq_11.paid_at__week - , subq_11.paid_at__month - , subq_11.paid_at__quarter - , subq_11.paid_at__year - , subq_11.paid_at__extract_year - , subq_11.paid_at__extract_quarter - , subq_11.paid_at__extract_month - , subq_11.paid_at__extract_day - , subq_11.paid_at__extract_dow - , subq_11.paid_at__extract_doy - , subq_11.booking__ds__day - , subq_11.booking__ds__week - , subq_11.booking__ds__month - , subq_11.booking__ds__quarter - , subq_11.booking__ds__year - , subq_11.booking__ds__extract_year - , subq_11.booking__ds__extract_quarter - , subq_11.booking__ds__extract_month - , subq_11.booking__ds__extract_day - , subq_11.booking__ds__extract_dow - , subq_11.booking__ds__extract_doy - , subq_11.booking__ds_partitioned__day - , subq_11.booking__ds_partitioned__week - , subq_11.booking__ds_partitioned__month - , subq_11.booking__ds_partitioned__quarter - , subq_11.booking__ds_partitioned__year - , subq_11.booking__ds_partitioned__extract_year - , subq_11.booking__ds_partitioned__extract_quarter - , subq_11.booking__ds_partitioned__extract_month - , subq_11.booking__ds_partitioned__extract_day - , subq_11.booking__ds_partitioned__extract_dow - , subq_11.booking__ds_partitioned__extract_doy - , subq_11.booking__paid_at__day - , subq_11.booking__paid_at__week - , subq_11.booking__paid_at__month - , subq_11.booking__paid_at__quarter - , subq_11.booking__paid_at__year - , subq_11.booking__paid_at__extract_year - , subq_11.booking__paid_at__extract_quarter - , subq_11.booking__paid_at__extract_month - , subq_11.booking__paid_at__extract_day - , subq_11.booking__paid_at__extract_dow - , subq_11.booking__paid_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.guest - , subq_11.host - , subq_11.booking__listing - , subq_11.booking__guest - , subq_11.booking__host - , subq_11.is_instant - , subq_11.booking__is_instant - , subq_11.bookings - , subq_11.instant_bookings - , subq_11.booking_value - , subq_11.max_booking_value - , subq_11.min_booking_value - , subq_11.bookers - , subq_11.average_booking_value - , subq_11.referred_bookings - , subq_11.median_booking_value - , subq_11.booking_value_p99 - , subq_11.discrete_booking_value_p99 - , subq_11.approximate_continuous_booking_value_p99 - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -379,137 +379,137 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_13.listing - ) subq_14 - ) subq_15 - ) subq_16 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_10.listing = subq_16.listing + subq_2.listing = subq_8.listing LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookers'] SELECT - subq_21.listing - , subq_21.listing__bookers + subq_13.listing + , subq_13.listing__bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_20.listing - , subq_20.bookers AS listing__bookers + subq_12.listing + , subq_12.bookers AS listing__bookers FROM ( -- Aggregate Measures SELECT - subq_19.listing - , COUNT(DISTINCT subq_19.bookers) AS bookers + subq_11.listing + , COUNT(DISTINCT subq_11.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_18.listing - , subq_18.bookers + subq_10.listing + , subq_10.bookers FROM ( -- Metric Time Dimension 'ds' SELECT - subq_17.ds__day - , subq_17.ds__week - , subq_17.ds__month - , subq_17.ds__quarter - , subq_17.ds__year - , subq_17.ds__extract_year - , subq_17.ds__extract_quarter - , subq_17.ds__extract_month - , subq_17.ds__extract_day - , subq_17.ds__extract_dow - , subq_17.ds__extract_doy - , subq_17.ds_partitioned__day - , subq_17.ds_partitioned__week - , subq_17.ds_partitioned__month - , subq_17.ds_partitioned__quarter - , subq_17.ds_partitioned__year - , subq_17.ds_partitioned__extract_year - , subq_17.ds_partitioned__extract_quarter - , subq_17.ds_partitioned__extract_month - , subq_17.ds_partitioned__extract_day - , subq_17.ds_partitioned__extract_dow - , subq_17.ds_partitioned__extract_doy - , subq_17.paid_at__day - , subq_17.paid_at__week - , subq_17.paid_at__month - , subq_17.paid_at__quarter - , subq_17.paid_at__year - , subq_17.paid_at__extract_year - , subq_17.paid_at__extract_quarter - , subq_17.paid_at__extract_month - , subq_17.paid_at__extract_day - , subq_17.paid_at__extract_dow - , subq_17.paid_at__extract_doy - , subq_17.booking__ds__day - , subq_17.booking__ds__week - , subq_17.booking__ds__month - , subq_17.booking__ds__quarter - , subq_17.booking__ds__year - , subq_17.booking__ds__extract_year - , subq_17.booking__ds__extract_quarter - , subq_17.booking__ds__extract_month - , subq_17.booking__ds__extract_day - , subq_17.booking__ds__extract_dow - , subq_17.booking__ds__extract_doy - , subq_17.booking__ds_partitioned__day - , subq_17.booking__ds_partitioned__week - , subq_17.booking__ds_partitioned__month - , subq_17.booking__ds_partitioned__quarter - , subq_17.booking__ds_partitioned__year - , subq_17.booking__ds_partitioned__extract_year - , subq_17.booking__ds_partitioned__extract_quarter - , subq_17.booking__ds_partitioned__extract_month - , subq_17.booking__ds_partitioned__extract_day - , subq_17.booking__ds_partitioned__extract_dow - , subq_17.booking__ds_partitioned__extract_doy - , subq_17.booking__paid_at__day - , subq_17.booking__paid_at__week - , subq_17.booking__paid_at__month - , subq_17.booking__paid_at__quarter - , subq_17.booking__paid_at__year - , subq_17.booking__paid_at__extract_year - , subq_17.booking__paid_at__extract_quarter - , subq_17.booking__paid_at__extract_month - , subq_17.booking__paid_at__extract_day - , subq_17.booking__paid_at__extract_dow - , subq_17.booking__paid_at__extract_doy - , subq_17.ds__day AS metric_time__day - , subq_17.ds__week AS metric_time__week - , subq_17.ds__month AS metric_time__month - , subq_17.ds__quarter AS metric_time__quarter - , subq_17.ds__year AS metric_time__year - , subq_17.ds__extract_year AS metric_time__extract_year - , subq_17.ds__extract_quarter AS metric_time__extract_quarter - , subq_17.ds__extract_month AS metric_time__extract_month - , subq_17.ds__extract_day AS metric_time__extract_day - , subq_17.ds__extract_dow AS metric_time__extract_dow - , subq_17.ds__extract_doy AS metric_time__extract_doy - , subq_17.listing - , subq_17.guest - , subq_17.host - , subq_17.booking__listing - , subq_17.booking__guest - , subq_17.booking__host - , subq_17.is_instant - , subq_17.booking__is_instant - , subq_17.bookings - , subq_17.instant_bookings - , subq_17.booking_value - , subq_17.max_booking_value - , subq_17.min_booking_value - , subq_17.bookers - , subq_17.average_booking_value - , subq_17.referred_bookings - , subq_17.median_booking_value - , subq_17.booking_value_p99 - , subq_17.discrete_booking_value_p99 - , subq_17.approximate_continuous_booking_value_p99 - , subq_17.approximate_discrete_booking_value_p99 + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.paid_at__day + , subq_9.paid_at__week + , subq_9.paid_at__month + , subq_9.paid_at__quarter + , subq_9.paid_at__year + , subq_9.paid_at__extract_year + , subq_9.paid_at__extract_quarter + , subq_9.paid_at__extract_month + , subq_9.paid_at__extract_day + , subq_9.paid_at__extract_dow + , subq_9.paid_at__extract_doy + , subq_9.booking__ds__day + , subq_9.booking__ds__week + , subq_9.booking__ds__month + , subq_9.booking__ds__quarter + , subq_9.booking__ds__year + , subq_9.booking__ds__extract_year + , subq_9.booking__ds__extract_quarter + , subq_9.booking__ds__extract_month + , subq_9.booking__ds__extract_day + , subq_9.booking__ds__extract_dow + , subq_9.booking__ds__extract_doy + , subq_9.booking__ds_partitioned__day + , subq_9.booking__ds_partitioned__week + , subq_9.booking__ds_partitioned__month + , subq_9.booking__ds_partitioned__quarter + , subq_9.booking__ds_partitioned__year + , subq_9.booking__ds_partitioned__extract_year + , subq_9.booking__ds_partitioned__extract_quarter + , subq_9.booking__ds_partitioned__extract_month + , subq_9.booking__ds_partitioned__extract_day + , subq_9.booking__ds_partitioned__extract_dow + , subq_9.booking__ds_partitioned__extract_doy + , subq_9.booking__paid_at__day + , subq_9.booking__paid_at__week + , subq_9.booking__paid_at__month + , subq_9.booking__paid_at__quarter + , subq_9.booking__paid_at__year + , subq_9.booking__paid_at__extract_year + , subq_9.booking__paid_at__extract_quarter + , subq_9.booking__paid_at__extract_month + , subq_9.booking__paid_at__extract_day + , subq_9.booking__paid_at__extract_dow + , subq_9.booking__paid_at__extract_doy + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__extract_day + , subq_9.ds__extract_dow AS metric_time__extract_dow + , subq_9.ds__extract_doy AS metric_time__extract_doy + , subq_9.listing + , subq_9.guest + , subq_9.host + , subq_9.booking__listing + , subq_9.booking__guest + , subq_9.booking__host + , subq_9.is_instant + , subq_9.booking__is_instant + , subq_9.bookings + , subq_9.instant_bookings + , subq_9.booking_value + , subq_9.max_booking_value + , subq_9.min_booking_value + , subq_9.bookers + , subq_9.average_booking_value + , subq_9.referred_bookings + , subq_9.median_booking_value + , subq_9.booking_value_p99 + , subq_9.discrete_booking_value_p99 + , subq_9.approximate_continuous_booking_value_p99 + , subq_9.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -602,19 +602,19 @@ 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_17 - ) subq_18 - ) subq_19 + ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_19.listing - ) subq_20 - ) subq_21 - ) subq_22 + subq_11.listing + ) subq_12 + ) subq_13 + ) subq_14 ON - subq_10.listing = subq_22.listing - ) subq_23 - ) subq_24 + subq_2.listing = subq_14.listing + ) subq_15 + ) subq_16 WHERE listing__bookings > 2 AND listing__bookers > 1 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql index 1846b78cd5..767f0b3fea 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_44.listing__bookings AS listing__bookings - , subq_50.listing__bookers AS listing__bookers - , subq_38.listings AS listings + subq_28.listing__bookings AS listing__bookings + , subq_34.listing__bookers AS listing__bookers + , subq_22.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -19,7 +19,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_38 + ) subq_22 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,12 +35,12 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_41 + ) subq_25 GROUP BY listing - ) subq_44 + ) subq_28 ON - subq_38.listing = subq_44.listing + subq_22.listing = subq_28.listing LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -54,8 +54,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_50 + ) subq_34 ON - subq_38.listing = subq_50.listing -) subq_52 + subq_22.listing = subq_34.listing +) subq_36 WHERE listing__bookings > 2 AND listing__bookers > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_ratio_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_ratio_metric_in_where_filter__plan0.sql index e13c570bf3..ff5fde9d58 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_ratio_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_ratio_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_31.listings + subq_20.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_30.listings) AS listings + SUM(subq_19.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_29.listings + subq_18.listings FROM ( -- Constrain Output with WHERE SELECT - subq_28.listing__bookings_per_booker - , subq_28.listings + subq_17.listing__bookings_per_booker + , subq_17.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - subq_27.listing__bookings_per_booker - , subq_27.listings + subq_16.listing__bookings_per_booker + , subq_16.listings FROM ( -- Join Standard Outputs SELECT - subq_13.listing AS listing - , subq_26.listing__bookings_per_booker AS listing__bookings_per_booker - , subq_13.listings AS listings + subq_2.listing AS listing + , subq_15.listing__bookings_per_booker AS listing__bookings_per_booker + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_12.listing - , subq_12.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,141 +160,141 @@ 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_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] SELECT - subq_25.listing - , subq_25.listing__bookings_per_booker + subq_14.listing + , subq_14.listing__bookings_per_booker FROM ( -- Compute Metrics via Expressions SELECT - subq_24.listing - , CAST(subq_24.bookings AS DOUBLE) / CAST(NULLIF(subq_24.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker + subq_13.listing + , CAST(subq_13.bookings AS DOUBLE) / CAST(NULLIF(subq_13.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_18.listing, subq_23.listing) AS listing - , MAX(subq_18.bookings) AS bookings - , MAX(subq_23.bookers) AS bookers + COALESCE(subq_7.listing, subq_12.listing) AS listing + , MAX(subq_7.bookings) AS bookings + , MAX(subq_12.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_17.listing - , subq_17.bookings + subq_6.listing + , subq_6.bookings FROM ( -- Aggregate Measures SELECT - subq_16.listing - , SUM(subq_16.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_15.listing - , subq_15.bookings + subq_4.listing + , subq_4.bookings 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_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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -387,129 +387,129 @@ 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_3 + ) subq_4 + ) subq_5 GROUP BY - subq_16.listing - ) subq_17 - ) subq_18 + subq_5.listing + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.listing - , subq_22.bookers + subq_11.listing + , subq_11.bookers FROM ( -- Aggregate Measures SELECT - subq_21.listing - , COUNT(DISTINCT subq_21.bookers) AS bookers + subq_10.listing + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_20.listing - , subq_20.bookers + subq_9.listing + , subq_9.bookers FROM ( -- Metric Time Dimension 'ds' 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.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -602,25 +602,25 @@ 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_19 - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_21.listing - ) subq_22 - ) subq_23 + subq_10.listing + ) subq_11 + ) subq_12 ON - subq_18.listing = subq_23.listing + subq_7.listing = subq_12.listing GROUP BY - COALESCE(subq_18.listing, subq_23.listing) - ) subq_24 - ) subq_25 - ) subq_26 + COALESCE(subq_7.listing, subq_12.listing) + ) subq_13 + ) subq_14 + ) subq_15 ON - subq_13.listing = subq_26.listing - ) subq_27 - ) subq_28 + subq_2.listing = subq_15.listing + ) subq_16 + ) subq_17 WHERE listing__bookings_per_booker > 1 - ) subq_29 - ) subq_30 -) subq_31 + ) subq_18 + ) subq_19 +) subq_20 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql index 35d30ee209..86e90a968e 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - CAST(subq_56.bookings AS DOUBLE) / CAST(NULLIF(subq_56.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker - , subq_45.listings AS listings + CAST(subq_34.bookings AS DOUBLE) / CAST(NULLIF(subq_34.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker + , subq_23.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,13 +18,13 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_45 + ) subq_23 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_50.listing, subq_55.listing) AS listing - , MAX(subq_50.bookings) AS bookings - , MAX(subq_55.bookers) AS bookers + COALESCE(subq_28.listing, subq_33.listing) AS listing + , MAX(subq_28.bookings) AS bookings + , MAX(subq_33.bookers) AS bookers FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,10 +39,10 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_48 + ) subq_26 GROUP BY listing - ) subq_50 + ) subq_28 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -55,13 +55,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_55 + ) subq_33 ON - subq_50.listing = subq_55.listing + subq_28.listing = subq_33.listing GROUP BY - COALESCE(subq_50.listing, subq_55.listing) - ) subq_56 + COALESCE(subq_28.listing, subq_33.listing) + ) subq_34 ON - subq_45.listing = subq_56.listing -) subq_60 + subq_23.listing = subq_34.listing +) subq_38 WHERE listing__bookings_per_booker > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_simple_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_simple_metric_in_where_filter__plan0.sql index 6fa974a0c3..df04d2c9e4 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_simple_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_simple_metric_in_where_filter__plan0.sql @@ -1,105 +1,105 @@ -- Compute Metrics via Expressions SELECT - subq_17.listings + subq_13.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_16.listings) AS listings + SUM(subq_12.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_15.listings + subq_11.listings FROM ( -- Constrain Output with WHERE SELECT - subq_14.listing__bookings - , subq_14.listings + subq_10.listing__bookings + , subq_10.listings FROM ( -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_13.listing__bookings - , subq_13.listings + subq_9.listing__bookings + , subq_9.listings FROM ( -- Join Standard Outputs SELECT - subq_6.listing AS listing - , subq_12.listing__bookings AS listing__bookings - , subq_6.listings AS listings + subq_2.listing AS listing + , subq_8.listing__bookings AS listing__bookings + , subq_2.listings AS listings FROM ( -- Pass Only Elements: ['listings', 'listing'] SELECT - subq_5.listing - , subq_5.listings + subq_1.listing + , subq_1.listings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.created_at__day - , subq_4.created_at__week - , subq_4.created_at__month - , subq_4.created_at__quarter - , subq_4.created_at__year - , subq_4.created_at__extract_year - , subq_4.created_at__extract_quarter - , subq_4.created_at__extract_month - , subq_4.created_at__extract_day - , subq_4.created_at__extract_dow - , subq_4.created_at__extract_doy - , subq_4.listing__ds__day - , subq_4.listing__ds__week - , subq_4.listing__ds__month - , subq_4.listing__ds__quarter - , subq_4.listing__ds__year - , subq_4.listing__ds__extract_year - , subq_4.listing__ds__extract_quarter - , subq_4.listing__ds__extract_month - , subq_4.listing__ds__extract_day - , subq_4.listing__ds__extract_dow - , subq_4.listing__ds__extract_doy - , subq_4.listing__created_at__day - , subq_4.listing__created_at__week - , subq_4.listing__created_at__month - , subq_4.listing__created_at__quarter - , subq_4.listing__created_at__year - , subq_4.listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month - , subq_4.listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.user - , subq_4.listing__user - , subq_4.country_latest - , subq_4.is_lux_latest - , subq_4.capacity_latest - , subq_4.listing__country_latest - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings - , subq_4.largest_listing - , subq_4.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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -160,130 +160,130 @@ 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_4 - ) subq_5 - ) subq_6 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['listing', 'listing__bookings'] SELECT - subq_11.listing - , subq_11.listing__bookings + subq_7.listing + , subq_7.listing__bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing - , subq_10.bookings AS listing__bookings + subq_6.listing + , subq_6.bookings AS listing__bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing - , SUM(subq_9.bookings) AS bookings + subq_5.listing + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_8.listing - , subq_8.bookings + subq_4.listing + , subq_4.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.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.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.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.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.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 ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -376,19 +376,19 @@ 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_7 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 + ) subq_5 GROUP BY - subq_9.listing - ) subq_10 - ) subq_11 - ) subq_12 + subq_5.listing + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_6.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_2.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE listing__bookings > 2 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_11 + ) subq_12 +) subq_13 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql index 98bdb265dd..48fed36d03 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql @@ -8,8 +8,8 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_30.listing__bookings AS listing__bookings - , subq_24.listings AS listings + subq_22.listing__bookings AS listing__bookings + , subq_16.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -18,7 +18,7 @@ FROM ( listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_24 + ) subq_16 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -34,11 +34,11 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_27 + ) subq_19 GROUP BY listing - ) subq_30 + ) subq_22 ON - subq_24.listing = subq_30.listing -) subq_32 + subq_16.listing = subq_22.listing +) subq_24 WHERE listing__bookings > 2 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql index b5c88a2d39..d1c06131a3 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day - , CAST(subq_15.average_booking_value AS FLOAT64) / CAST(NULLIF(subq_15.max_booking_value, 0) AS FLOAT64) AS instant_booking_fraction_of_max_value + subq_13.metric_time__day + , CAST(subq_13.average_booking_value AS FLOAT64) / CAST(NULLIF(subq_13.max_booking_value, 0) AS FLOAT64) 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 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) AS metric_time__day + , MAX(subq_7.average_booking_value) AS average_booking_value + , MAX(subq_12.max_booking_value) AS max_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_6.metric_time__day + , subq_6.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , AVG(subq_7.average_booking_value) AS average_booking_value + subq_5.metric_time__day + , AVG(subq_5.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 + subq_4.metric_time__day + , subq_4.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.average_booking_value + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.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 + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY metric_time__day - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.max_booking_value + subq_11.metric_time__day + , subq_11.max_booking_value FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , MAX(subq_12.max_booking_value) AS max_booking_value + subq_10.metric_time__day + , MAX(subq_10.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 + subq_9.metric_time__day + , subq_9.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- 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_10 - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY metric_time__day - ) subq_13 - ) subq_14 + ) subq_11 + ) subq_12 ON - subq_9.metric_time__day = subq_14.metric_time__day + subq_7.metric_time__day = subq_12.metric_time__day GROUP BY metric_time__day -) subq_15 +) subq_13 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql index e9ff505215..dff0096f7c 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_25.average_booking_value) AS average_booking_value - , MAX(subq_30.max_booking_value) AS max_booking_value + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) AS metric_time__day + , MAX(subq_21.average_booking_value) AS average_booking_value + , MAX(subq_26.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_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_25 + ) subq_21 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 metric_time__day - ) subq_30 + ) subq_26 ON - subq_25.metric_time__day = subq_30.metric_time__day + subq_21.metric_time__day = subq_26.metric_time__day GROUP BY metric_time__day -) subq_31 +) subq_27 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_multiple_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_multiple_categorical_dimension_pushdown__plan0.sql index c984a7db7b..5bf9f02a6f 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_multiple_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_multiple_categorical_dimension_pushdown__plan0.sql @@ -1,186 +1,186 @@ -- Compute Metrics via Expressions SELECT - subq_12.user__home_state_latest - , subq_12.listings + subq_10.user__home_state_latest + , subq_10.listings FROM ( -- Aggregate Measures SELECT - subq_11.user__home_state_latest - , SUM(subq_11.listings) AS listings + subq_9.user__home_state_latest + , SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_10.user__home_state_latest - , subq_10.listings + subq_8.user__home_state_latest + , subq_8.listings FROM ( -- Constrain Output with WHERE SELECT - subq_9.listing__is_lux_latest - , subq_9.listing__capacity_latest - , subq_9.user__home_state_latest - , subq_9.listings + subq_7.listing__is_lux_latest + , subq_7.listing__capacity_latest + , subq_7.user__home_state_latest + , subq_7.listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_8.listing__is_lux_latest - , subq_8.listing__capacity_latest - , subq_8.user__home_state_latest - , subq_8.listings + subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.user__home_state_latest + , subq_6.listings FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.user AS user + , 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 FROM ( -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_4.user - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings + subq_2.user + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings 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.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 - , 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_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.created_at__day + , subq_1.created_at__week + , subq_1.created_at__month + , subq_1.created_at__quarter + , subq_1.created_at__year + , subq_1.created_at__extract_year + , subq_1.created_at__extract_quarter + , subq_1.created_at__extract_month + , subq_1.created_at__extract_day + , subq_1.created_at__extract_dow + , subq_1.created_at__extract_doy + , subq_1.listing__ds__day + , subq_1.listing__ds__week + , subq_1.listing__ds__month + , subq_1.listing__ds__quarter + , subq_1.listing__ds__year + , subq_1.listing__ds__extract_year + , subq_1.listing__ds__extract_quarter + , subq_1.listing__ds__extract_month + , subq_1.listing__ds__extract_day + , subq_1.listing__ds__extract_dow + , subq_1.listing__ds__extract_doy + , subq_1.listing__created_at__day + , subq_1.listing__created_at__week + , subq_1.listing__created_at__month + , subq_1.listing__created_at__quarter + , subq_1.listing__created_at__year + , subq_1.listing__created_at__extract_year + , subq_1.listing__created_at__extract_quarter + , subq_1.listing__created_at__extract_month + , subq_1.listing__created_at__extract_day + , subq_1.listing__created_at__extract_dow + , subq_1.listing__created_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.user + , subq_1.listing__user + , subq_1.country_latest + , subq_1.is_lux_latest + , subq_1.capacity_latest + , subq_1.listing__country_latest + , subq_1.listing__is_lux_latest + , subq_1.listing__capacity_latest + , subq_1.listings + , subq_1.largest_listing + , subq_1.smallest_listing 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.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 + 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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -241,16 +241,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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 LEFT 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 @@ -280,15 +280,15 @@ 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_5.user = subq_7.user - ) subq_8 - ) subq_9 + subq_3.user = subq_5.user + ) subq_6 + ) subq_7 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_10 - ) subq_11 + ) subq_8 + ) subq_9 GROUP BY user__home_state_latest -) subq_12 +) subq_10 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql index ed5fac3404..66b2f06ffb 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql @@ -9,15 +9,15 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_18.listing__is_lux_latest AS listing__is_lux_latest - , subq_18.listing__capacity_latest AS listing__capacity_latest + subq_14.listing__is_lux_latest AS listing__is_lux_latest + , subq_14.listing__capacity_latest AS listing__capacity_latest , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_18.listings AS listings + , subq_14.listings AS listings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_16.user + subq_12.user , listing__is_lux_latest , listing__capacity_latest , listings @@ -30,14 +30,14 @@ FROM ( , capacity AS listing__capacity_latest , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_12 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_18 + ) subq_14 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_18.user = users_latest_src_28000.user_id -) subq_22 + subq_14.user = users_latest_src_28000.user_id +) subq_18 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_single_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_single_categorical_dimension_pushdown__plan0.sql index 8a18d11644..964360ab5e 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_single_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_single_categorical_dimension_pushdown__plan0.sql @@ -1,244 +1,244 @@ -- Compute Metrics via Expressions SELECT - subq_13.listing__country_latest - , subq_13.bookings + subq_11.listing__country_latest + , subq_11.bookings FROM ( -- Aggregate Measures SELECT - subq_12.listing__country_latest - , SUM(subq_12.bookings) AS bookings + subq_10.listing__country_latest + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_11.listing__country_latest - , subq_11.bookings + subq_9.listing__country_latest + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_10.booking__is_instant - , subq_10.listing__country_latest - , subq_10.bookings + subq_8.booking__is_instant + , subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_9.booking__is_instant - , subq_9.listing__country_latest - , subq_9.bookings + subq_7.booking__is_instant + , subq_7.listing__country_latest + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.listing AS listing + , subq_3.booking__is_instant AS booking__is_instant + , subq_6.country_latest AS listing__country_latest + , subq_3.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_4.listing - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.listing + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_7.listing - , subq_7.country_latest + subq_5.listing + , subq_5.country_latest 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.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 + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.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_6 - ) subq_7 - ) subq_8 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 WHERE booking__is_instant - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY listing__country_latest -) subq_13 +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_single_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_single_categorical_dimension_pushdown__plan0_optimized.sql index cac7f544c4..287a6293ca 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_single_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/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_19.booking__is_instant AS booking__is_instant + subq_15.booking__is_instant AS booking__is_instant , listings_latest_src_28000.country AS listing__country_latest - , subq_19.bookings AS bookings + , subq_15.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_17 + ) subq_13 WHERE booking__is_instant - ) subq_19 + ) subq_15 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_19.listing = listings_latest_src_28000.listing_id -) subq_24 + subq_15.listing = listings_latest_src_28000.listing_id +) subq_20 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql index 5d770f3f36..b3263dd7a8 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -1,242 +1,242 @@ -- 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 + subq_13.metric_time__day + , CAST(subq_13.average_booking_value AS DOUBLE) / CAST(NULLIF(subq_13.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 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) AS metric_time__day + , MAX(subq_7.average_booking_value) AS average_booking_value + , MAX(subq_12.max_booking_value) AS max_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_6.metric_time__day + , subq_6.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , AVG(subq_7.average_booking_value) AS average_booking_value + subq_5.metric_time__day + , AVG(subq_5.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 + subq_4.metric_time__day + , subq_4.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.average_booking_value + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.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 + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_5.metric_time__day + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.max_booking_value + subq_11.metric_time__day + , subq_11.max_booking_value FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , MAX(subq_12.max_booking_value) AS max_booking_value + subq_10.metric_time__day + , MAX(subq_10.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 + subq_9.metric_time__day + , subq_9.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- 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_10 - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day - ) subq_13 - ) subq_14 + subq_10.metric_time__day + ) subq_11 + ) subq_12 ON - subq_9.metric_time__day = subq_14.metric_time__day + subq_7.metric_time__day = subq_12.metric_time__day GROUP BY - COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) +) subq_13 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql index 0297d39f0b..f3e1c64002 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_25.average_booking_value) AS average_booking_value - , MAX(subq_30.max_booking_value) AS max_booking_value + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) AS metric_time__day + , MAX(subq_21.average_booking_value) AS average_booking_value + , MAX(subq_26.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_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_25 + ) subq_21 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_30 + ) subq_26 ON - subq_25.metric_time__day = subq_30.metric_time__day + subq_21.metric_time__day = subq_26.metric_time__day GROUP BY - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) +) subq_27 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_multiple_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_multiple_categorical_dimension_pushdown__plan0.sql index 35f2ac06a8..c406c750ca 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_multiple_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_multiple_categorical_dimension_pushdown__plan0.sql @@ -1,186 +1,186 @@ -- Compute Metrics via Expressions SELECT - subq_12.user__home_state_latest - , subq_12.listings + subq_10.user__home_state_latest + , subq_10.listings FROM ( -- Aggregate Measures SELECT - subq_11.user__home_state_latest - , SUM(subq_11.listings) AS listings + subq_9.user__home_state_latest + , SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_10.user__home_state_latest - , subq_10.listings + subq_8.user__home_state_latest + , subq_8.listings FROM ( -- Constrain Output with WHERE SELECT - subq_9.listing__is_lux_latest - , subq_9.listing__capacity_latest - , subq_9.user__home_state_latest - , subq_9.listings + subq_7.listing__is_lux_latest + , subq_7.listing__capacity_latest + , subq_7.user__home_state_latest + , subq_7.listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_8.listing__is_lux_latest - , subq_8.listing__capacity_latest - , subq_8.user__home_state_latest - , subq_8.listings + subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.user__home_state_latest + , subq_6.listings FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.user AS user + , 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 FROM ( -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_4.user - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings + subq_2.user + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings 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.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 - , 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_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.created_at__day + , subq_1.created_at__week + , subq_1.created_at__month + , subq_1.created_at__quarter + , subq_1.created_at__year + , subq_1.created_at__extract_year + , subq_1.created_at__extract_quarter + , subq_1.created_at__extract_month + , subq_1.created_at__extract_day + , subq_1.created_at__extract_dow + , subq_1.created_at__extract_doy + , subq_1.listing__ds__day + , subq_1.listing__ds__week + , subq_1.listing__ds__month + , subq_1.listing__ds__quarter + , subq_1.listing__ds__year + , subq_1.listing__ds__extract_year + , subq_1.listing__ds__extract_quarter + , subq_1.listing__ds__extract_month + , subq_1.listing__ds__extract_day + , subq_1.listing__ds__extract_dow + , subq_1.listing__ds__extract_doy + , subq_1.listing__created_at__day + , subq_1.listing__created_at__week + , subq_1.listing__created_at__month + , subq_1.listing__created_at__quarter + , subq_1.listing__created_at__year + , subq_1.listing__created_at__extract_year + , subq_1.listing__created_at__extract_quarter + , subq_1.listing__created_at__extract_month + , subq_1.listing__created_at__extract_day + , subq_1.listing__created_at__extract_dow + , subq_1.listing__created_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.user + , subq_1.listing__user + , subq_1.country_latest + , subq_1.is_lux_latest + , subq_1.capacity_latest + , subq_1.listing__country_latest + , subq_1.listing__is_lux_latest + , subq_1.listing__capacity_latest + , subq_1.listings + , subq_1.largest_listing + , subq_1.smallest_listing 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.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 + 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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -241,16 +241,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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 LEFT 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 @@ -280,15 +280,15 @@ 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_5.user = subq_7.user - ) subq_8 - ) subq_9 + subq_3.user = subq_5.user + ) subq_6 + ) subq_7 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_10 - ) subq_11 + ) subq_8 + ) subq_9 GROUP BY - subq_11.user__home_state_latest -) subq_12 + subq_9.user__home_state_latest +) subq_10 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql index ed5fac3404..66b2f06ffb 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql @@ -9,15 +9,15 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_18.listing__is_lux_latest AS listing__is_lux_latest - , subq_18.listing__capacity_latest AS listing__capacity_latest + subq_14.listing__is_lux_latest AS listing__is_lux_latest + , subq_14.listing__capacity_latest AS listing__capacity_latest , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_18.listings AS listings + , subq_14.listings AS listings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_16.user + subq_12.user , listing__is_lux_latest , listing__capacity_latest , listings @@ -30,14 +30,14 @@ FROM ( , capacity AS listing__capacity_latest , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_12 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_18 + ) subq_14 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_18.user = users_latest_src_28000.user_id -) subq_22 + subq_14.user = users_latest_src_28000.user_id +) subq_18 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_single_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_single_categorical_dimension_pushdown__plan0.sql index 41d8a84d8a..24a9691527 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_single_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_single_categorical_dimension_pushdown__plan0.sql @@ -1,244 +1,244 @@ -- Compute Metrics via Expressions SELECT - subq_13.listing__country_latest - , subq_13.bookings + subq_11.listing__country_latest + , subq_11.bookings FROM ( -- Aggregate Measures SELECT - subq_12.listing__country_latest - , SUM(subq_12.bookings) AS bookings + subq_10.listing__country_latest + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_11.listing__country_latest - , subq_11.bookings + subq_9.listing__country_latest + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_10.booking__is_instant - , subq_10.listing__country_latest - , subq_10.bookings + subq_8.booking__is_instant + , subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_9.booking__is_instant - , subq_9.listing__country_latest - , subq_9.bookings + subq_7.booking__is_instant + , subq_7.listing__country_latest + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.listing AS listing + , subq_3.booking__is_instant AS booking__is_instant + , subq_6.country_latest AS listing__country_latest + , subq_3.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_4.listing - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.listing + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_7.listing - , subq_7.country_latest + subq_5.listing + , subq_5.country_latest 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.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 + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.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_6 - ) subq_7 - ) subq_8 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 WHERE booking__is_instant - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY - subq_12.listing__country_latest -) subq_13 + subq_10.listing__country_latest +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_single_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_single_categorical_dimension_pushdown__plan0_optimized.sql index cac7f544c4..287a6293ca 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_single_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/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_19.booking__is_instant AS booking__is_instant + subq_15.booking__is_instant AS booking__is_instant , listings_latest_src_28000.country AS listing__country_latest - , subq_19.bookings AS bookings + , subq_15.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_17 + ) subq_13 WHERE booking__is_instant - ) subq_19 + ) subq_15 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_19.listing = listings_latest_src_28000.listing_id -) subq_24 + subq_15.listing = listings_latest_src_28000.listing_id +) subq_20 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql index 9912778c27..f5177b5dd2 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day - , CAST(subq_15.average_booking_value AS DOUBLE PRECISION) / CAST(NULLIF(subq_15.max_booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_fraction_of_max_value + subq_13.metric_time__day + , CAST(subq_13.average_booking_value AS DOUBLE PRECISION) / CAST(NULLIF(subq_13.max_booking_value, 0) AS DOUBLE PRECISION) 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 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) AS metric_time__day + , MAX(subq_7.average_booking_value) AS average_booking_value + , MAX(subq_12.max_booking_value) AS max_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_6.metric_time__day + , subq_6.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , AVG(subq_7.average_booking_value) AS average_booking_value + subq_5.metric_time__day + , AVG(subq_5.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 + subq_4.metric_time__day + , subq_4.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.average_booking_value + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.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 + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_5.metric_time__day + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.max_booking_value + subq_11.metric_time__day + , subq_11.max_booking_value FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , MAX(subq_12.max_booking_value) AS max_booking_value + subq_10.metric_time__day + , MAX(subq_10.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 + subq_9.metric_time__day + , subq_9.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- 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_10 - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day - ) subq_13 - ) subq_14 + subq_10.metric_time__day + ) subq_11 + ) subq_12 ON - subq_9.metric_time__day = subq_14.metric_time__day + subq_7.metric_time__day = subq_12.metric_time__day GROUP BY - COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) +) subq_13 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql index 488ab03066..300cf6b8a9 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_25.average_booking_value) AS average_booking_value - , MAX(subq_30.max_booking_value) AS max_booking_value + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) AS metric_time__day + , MAX(subq_21.average_booking_value) AS average_booking_value + , MAX(subq_26.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_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_25 + ) subq_21 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_30 + ) subq_26 ON - subq_25.metric_time__day = subq_30.metric_time__day + subq_21.metric_time__day = subq_26.metric_time__day GROUP BY - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) +) subq_27 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_multiple_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_multiple_categorical_dimension_pushdown__plan0.sql index e20f1a70d6..7c263d3904 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_multiple_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_multiple_categorical_dimension_pushdown__plan0.sql @@ -1,186 +1,186 @@ -- Compute Metrics via Expressions SELECT - subq_12.user__home_state_latest - , subq_12.listings + subq_10.user__home_state_latest + , subq_10.listings FROM ( -- Aggregate Measures SELECT - subq_11.user__home_state_latest - , SUM(subq_11.listings) AS listings + subq_9.user__home_state_latest + , SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_10.user__home_state_latest - , subq_10.listings + subq_8.user__home_state_latest + , subq_8.listings FROM ( -- Constrain Output with WHERE SELECT - subq_9.listing__is_lux_latest - , subq_9.listing__capacity_latest - , subq_9.user__home_state_latest - , subq_9.listings + subq_7.listing__is_lux_latest + , subq_7.listing__capacity_latest + , subq_7.user__home_state_latest + , subq_7.listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_8.listing__is_lux_latest - , subq_8.listing__capacity_latest - , subq_8.user__home_state_latest - , subq_8.listings + subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.user__home_state_latest + , subq_6.listings FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.user AS user + , 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 FROM ( -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_4.user - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings + subq_2.user + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings 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.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 - , 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_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.created_at__day + , subq_1.created_at__week + , subq_1.created_at__month + , subq_1.created_at__quarter + , subq_1.created_at__year + , subq_1.created_at__extract_year + , subq_1.created_at__extract_quarter + , subq_1.created_at__extract_month + , subq_1.created_at__extract_day + , subq_1.created_at__extract_dow + , subq_1.created_at__extract_doy + , subq_1.listing__ds__day + , subq_1.listing__ds__week + , subq_1.listing__ds__month + , subq_1.listing__ds__quarter + , subq_1.listing__ds__year + , subq_1.listing__ds__extract_year + , subq_1.listing__ds__extract_quarter + , subq_1.listing__ds__extract_month + , subq_1.listing__ds__extract_day + , subq_1.listing__ds__extract_dow + , subq_1.listing__ds__extract_doy + , subq_1.listing__created_at__day + , subq_1.listing__created_at__week + , subq_1.listing__created_at__month + , subq_1.listing__created_at__quarter + , subq_1.listing__created_at__year + , subq_1.listing__created_at__extract_year + , subq_1.listing__created_at__extract_quarter + , subq_1.listing__created_at__extract_month + , subq_1.listing__created_at__extract_day + , subq_1.listing__created_at__extract_dow + , subq_1.listing__created_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.user + , subq_1.listing__user + , subq_1.country_latest + , subq_1.is_lux_latest + , subq_1.capacity_latest + , subq_1.listing__country_latest + , subq_1.listing__is_lux_latest + , subq_1.listing__capacity_latest + , subq_1.listings + , subq_1.largest_listing + , subq_1.smallest_listing 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.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 + 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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -241,16 +241,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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 LEFT 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 @@ -280,15 +280,15 @@ 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_5.user = subq_7.user - ) subq_8 - ) subq_9 + subq_3.user = subq_5.user + ) subq_6 + ) subq_7 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_10 - ) subq_11 + ) subq_8 + ) subq_9 GROUP BY - subq_11.user__home_state_latest -) subq_12 + subq_9.user__home_state_latest +) subq_10 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql index ed5fac3404..66b2f06ffb 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql @@ -9,15 +9,15 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_18.listing__is_lux_latest AS listing__is_lux_latest - , subq_18.listing__capacity_latest AS listing__capacity_latest + subq_14.listing__is_lux_latest AS listing__is_lux_latest + , subq_14.listing__capacity_latest AS listing__capacity_latest , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_18.listings AS listings + , subq_14.listings AS listings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_16.user + subq_12.user , listing__is_lux_latest , listing__capacity_latest , listings @@ -30,14 +30,14 @@ FROM ( , capacity AS listing__capacity_latest , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_12 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_18 + ) subq_14 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_18.user = users_latest_src_28000.user_id -) subq_22 + subq_14.user = users_latest_src_28000.user_id +) subq_18 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_single_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_single_categorical_dimension_pushdown__plan0.sql index 388b3ec95a..8dea2f0d03 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_single_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_single_categorical_dimension_pushdown__plan0.sql @@ -1,244 +1,244 @@ -- Compute Metrics via Expressions SELECT - subq_13.listing__country_latest - , subq_13.bookings + subq_11.listing__country_latest + , subq_11.bookings FROM ( -- Aggregate Measures SELECT - subq_12.listing__country_latest - , SUM(subq_12.bookings) AS bookings + subq_10.listing__country_latest + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_11.listing__country_latest - , subq_11.bookings + subq_9.listing__country_latest + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_10.booking__is_instant - , subq_10.listing__country_latest - , subq_10.bookings + subq_8.booking__is_instant + , subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_9.booking__is_instant - , subq_9.listing__country_latest - , subq_9.bookings + subq_7.booking__is_instant + , subq_7.listing__country_latest + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.listing AS listing + , subq_3.booking__is_instant AS booking__is_instant + , subq_6.country_latest AS listing__country_latest + , subq_3.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_4.listing - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.listing + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_7.listing - , subq_7.country_latest + subq_5.listing + , subq_5.country_latest 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.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 + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.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_6 - ) subq_7 - ) subq_8 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 WHERE booking__is_instant - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY - subq_12.listing__country_latest -) subq_13 + subq_10.listing__country_latest +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_single_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_single_categorical_dimension_pushdown__plan0_optimized.sql index cac7f544c4..287a6293ca 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_single_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/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_19.booking__is_instant AS booking__is_instant + subq_15.booking__is_instant AS booking__is_instant , listings_latest_src_28000.country AS listing__country_latest - , subq_19.bookings AS bookings + , subq_15.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_17 + ) subq_13 WHERE booking__is_instant - ) subq_19 + ) subq_15 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_19.listing = listings_latest_src_28000.listing_id -) subq_24 + subq_15.listing = listings_latest_src_28000.listing_id +) subq_20 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql index 6a9a9bf836..414ad9ce1b 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day - , CAST(subq_15.average_booking_value AS DOUBLE PRECISION) / CAST(NULLIF(subq_15.max_booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_fraction_of_max_value + subq_13.metric_time__day + , CAST(subq_13.average_booking_value AS DOUBLE PRECISION) / CAST(NULLIF(subq_13.max_booking_value, 0) AS DOUBLE PRECISION) 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 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) AS metric_time__day + , MAX(subq_7.average_booking_value) AS average_booking_value + , MAX(subq_12.max_booking_value) AS max_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_6.metric_time__day + , subq_6.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , AVG(subq_7.average_booking_value) AS average_booking_value + subq_5.metric_time__day + , AVG(subq_5.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 + subq_4.metric_time__day + , subq_4.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.average_booking_value + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.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 + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_5.metric_time__day + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.max_booking_value + subq_11.metric_time__day + , subq_11.max_booking_value FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , MAX(subq_12.max_booking_value) AS max_booking_value + subq_10.metric_time__day + , MAX(subq_10.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 + subq_9.metric_time__day + , subq_9.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- 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_10 - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day - ) subq_13 - ) subq_14 + subq_10.metric_time__day + ) subq_11 + ) subq_12 ON - subq_9.metric_time__day = subq_14.metric_time__day + subq_7.metric_time__day = subq_12.metric_time__day GROUP BY - COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) +) subq_13 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql index 488ab03066..300cf6b8a9 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_25.average_booking_value) AS average_booking_value - , MAX(subq_30.max_booking_value) AS max_booking_value + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) AS metric_time__day + , MAX(subq_21.average_booking_value) AS average_booking_value + , MAX(subq_26.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_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_25 + ) subq_21 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_30 + ) subq_26 ON - subq_25.metric_time__day = subq_30.metric_time__day + subq_21.metric_time__day = subq_26.metric_time__day GROUP BY - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) +) subq_27 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_multiple_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_multiple_categorical_dimension_pushdown__plan0.sql index e889913967..b0fdedb4d8 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_multiple_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_multiple_categorical_dimension_pushdown__plan0.sql @@ -1,186 +1,186 @@ -- Compute Metrics via Expressions SELECT - subq_12.user__home_state_latest - , subq_12.listings + subq_10.user__home_state_latest + , subq_10.listings FROM ( -- Aggregate Measures SELECT - subq_11.user__home_state_latest - , SUM(subq_11.listings) AS listings + subq_9.user__home_state_latest + , SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_10.user__home_state_latest - , subq_10.listings + subq_8.user__home_state_latest + , subq_8.listings FROM ( -- Constrain Output with WHERE SELECT - subq_9.listing__is_lux_latest - , subq_9.listing__capacity_latest - , subq_9.user__home_state_latest - , subq_9.listings + subq_7.listing__is_lux_latest + , subq_7.listing__capacity_latest + , subq_7.user__home_state_latest + , subq_7.listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_8.listing__is_lux_latest - , subq_8.listing__capacity_latest - , subq_8.user__home_state_latest - , subq_8.listings + subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.user__home_state_latest + , subq_6.listings FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.user AS user + , 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 FROM ( -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_4.user - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings + subq_2.user + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings 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.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 - , 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_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.created_at__day + , subq_1.created_at__week + , subq_1.created_at__month + , subq_1.created_at__quarter + , subq_1.created_at__year + , subq_1.created_at__extract_year + , subq_1.created_at__extract_quarter + , subq_1.created_at__extract_month + , subq_1.created_at__extract_day + , subq_1.created_at__extract_dow + , subq_1.created_at__extract_doy + , subq_1.listing__ds__day + , subq_1.listing__ds__week + , subq_1.listing__ds__month + , subq_1.listing__ds__quarter + , subq_1.listing__ds__year + , subq_1.listing__ds__extract_year + , subq_1.listing__ds__extract_quarter + , subq_1.listing__ds__extract_month + , subq_1.listing__ds__extract_day + , subq_1.listing__ds__extract_dow + , subq_1.listing__ds__extract_doy + , subq_1.listing__created_at__day + , subq_1.listing__created_at__week + , subq_1.listing__created_at__month + , subq_1.listing__created_at__quarter + , subq_1.listing__created_at__year + , subq_1.listing__created_at__extract_year + , subq_1.listing__created_at__extract_quarter + , subq_1.listing__created_at__extract_month + , subq_1.listing__created_at__extract_day + , subq_1.listing__created_at__extract_dow + , subq_1.listing__created_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.user + , subq_1.listing__user + , subq_1.country_latest + , subq_1.is_lux_latest + , subq_1.capacity_latest + , subq_1.listing__country_latest + , subq_1.listing__is_lux_latest + , subq_1.listing__capacity_latest + , subq_1.listings + , subq_1.largest_listing + , subq_1.smallest_listing 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.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 + 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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -241,16 +241,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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 LEFT 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 @@ -280,15 +280,15 @@ 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_5.user = subq_7.user - ) subq_8 - ) subq_9 + subq_3.user = subq_5.user + ) subq_6 + ) subq_7 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_10 - ) subq_11 + ) subq_8 + ) subq_9 GROUP BY - subq_11.user__home_state_latest -) subq_12 + subq_9.user__home_state_latest +) subq_10 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql index ed5fac3404..66b2f06ffb 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql @@ -9,15 +9,15 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_18.listing__is_lux_latest AS listing__is_lux_latest - , subq_18.listing__capacity_latest AS listing__capacity_latest + subq_14.listing__is_lux_latest AS listing__is_lux_latest + , subq_14.listing__capacity_latest AS listing__capacity_latest , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_18.listings AS listings + , subq_14.listings AS listings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_16.user + subq_12.user , listing__is_lux_latest , listing__capacity_latest , listings @@ -30,14 +30,14 @@ FROM ( , capacity AS listing__capacity_latest , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_12 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_18 + ) subq_14 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_18.user = users_latest_src_28000.user_id -) subq_22 + subq_14.user = users_latest_src_28000.user_id +) subq_18 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_single_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_single_categorical_dimension_pushdown__plan0.sql index 107ed57509..facc7e31b3 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_single_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_single_categorical_dimension_pushdown__plan0.sql @@ -1,244 +1,244 @@ -- Compute Metrics via Expressions SELECT - subq_13.listing__country_latest - , subq_13.bookings + subq_11.listing__country_latest + , subq_11.bookings FROM ( -- Aggregate Measures SELECT - subq_12.listing__country_latest - , SUM(subq_12.bookings) AS bookings + subq_10.listing__country_latest + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_11.listing__country_latest - , subq_11.bookings + subq_9.listing__country_latest + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_10.booking__is_instant - , subq_10.listing__country_latest - , subq_10.bookings + subq_8.booking__is_instant + , subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_9.booking__is_instant - , subq_9.listing__country_latest - , subq_9.bookings + subq_7.booking__is_instant + , subq_7.listing__country_latest + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.listing AS listing + , subq_3.booking__is_instant AS booking__is_instant + , subq_6.country_latest AS listing__country_latest + , subq_3.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_4.listing - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.listing + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_7.listing - , subq_7.country_latest + subq_5.listing + , subq_5.country_latest 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.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 + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.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_6 - ) subq_7 - ) subq_8 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 WHERE booking__is_instant - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY - subq_12.listing__country_latest -) subq_13 + subq_10.listing__country_latest +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_single_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_single_categorical_dimension_pushdown__plan0_optimized.sql index cac7f544c4..287a6293ca 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_single_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/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_19.booking__is_instant AS booking__is_instant + subq_15.booking__is_instant AS booking__is_instant , listings_latest_src_28000.country AS listing__country_latest - , subq_19.bookings AS bookings + , subq_15.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_17 + ) subq_13 WHERE booking__is_instant - ) subq_19 + ) subq_15 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_19.listing = listings_latest_src_28000.listing_id -) subq_24 + subq_15.listing = listings_latest_src_28000.listing_id +) subq_20 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql index b99de580a3..a988c8eb4b 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -1,242 +1,242 @@ -- 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 + subq_13.metric_time__day + , CAST(subq_13.average_booking_value AS DOUBLE) / CAST(NULLIF(subq_13.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 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) AS metric_time__day + , MAX(subq_7.average_booking_value) AS average_booking_value + , MAX(subq_12.max_booking_value) AS max_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_6.metric_time__day + , subq_6.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , AVG(subq_7.average_booking_value) AS average_booking_value + subq_5.metric_time__day + , AVG(subq_5.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 + subq_4.metric_time__day + , subq_4.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.average_booking_value + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.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 + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_5.metric_time__day + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.max_booking_value + subq_11.metric_time__day + , subq_11.max_booking_value FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , MAX(subq_12.max_booking_value) AS max_booking_value + subq_10.metric_time__day + , MAX(subq_10.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 + subq_9.metric_time__day + , subq_9.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- 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_10 - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day - ) subq_13 - ) subq_14 + subq_10.metric_time__day + ) subq_11 + ) subq_12 ON - subq_9.metric_time__day = subq_14.metric_time__day + subq_7.metric_time__day = subq_12.metric_time__day GROUP BY - COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) +) subq_13 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql index 0297d39f0b..f3e1c64002 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_25.average_booking_value) AS average_booking_value - , MAX(subq_30.max_booking_value) AS max_booking_value + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) AS metric_time__day + , MAX(subq_21.average_booking_value) AS average_booking_value + , MAX(subq_26.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_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_25 + ) subq_21 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_30 + ) subq_26 ON - subq_25.metric_time__day = subq_30.metric_time__day + subq_21.metric_time__day = subq_26.metric_time__day GROUP BY - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) +) subq_27 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_multiple_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_multiple_categorical_dimension_pushdown__plan0.sql index e1c91ce539..7ff089eef7 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_multiple_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_multiple_categorical_dimension_pushdown__plan0.sql @@ -1,186 +1,186 @@ -- Compute Metrics via Expressions SELECT - subq_12.user__home_state_latest - , subq_12.listings + subq_10.user__home_state_latest + , subq_10.listings FROM ( -- Aggregate Measures SELECT - subq_11.user__home_state_latest - , SUM(subq_11.listings) AS listings + subq_9.user__home_state_latest + , SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_10.user__home_state_latest - , subq_10.listings + subq_8.user__home_state_latest + , subq_8.listings FROM ( -- Constrain Output with WHERE SELECT - subq_9.listing__is_lux_latest - , subq_9.listing__capacity_latest - , subq_9.user__home_state_latest - , subq_9.listings + subq_7.listing__is_lux_latest + , subq_7.listing__capacity_latest + , subq_7.user__home_state_latest + , subq_7.listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_8.listing__is_lux_latest - , subq_8.listing__capacity_latest - , subq_8.user__home_state_latest - , subq_8.listings + subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.user__home_state_latest + , subq_6.listings FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.user AS user + , 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 FROM ( -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_4.user - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings + subq_2.user + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings 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.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 - , 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_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.created_at__day + , subq_1.created_at__week + , subq_1.created_at__month + , subq_1.created_at__quarter + , subq_1.created_at__year + , subq_1.created_at__extract_year + , subq_1.created_at__extract_quarter + , subq_1.created_at__extract_month + , subq_1.created_at__extract_day + , subq_1.created_at__extract_dow + , subq_1.created_at__extract_doy + , subq_1.listing__ds__day + , subq_1.listing__ds__week + , subq_1.listing__ds__month + , subq_1.listing__ds__quarter + , subq_1.listing__ds__year + , subq_1.listing__ds__extract_year + , subq_1.listing__ds__extract_quarter + , subq_1.listing__ds__extract_month + , subq_1.listing__ds__extract_day + , subq_1.listing__ds__extract_dow + , subq_1.listing__ds__extract_doy + , subq_1.listing__created_at__day + , subq_1.listing__created_at__week + , subq_1.listing__created_at__month + , subq_1.listing__created_at__quarter + , subq_1.listing__created_at__year + , subq_1.listing__created_at__extract_year + , subq_1.listing__created_at__extract_quarter + , subq_1.listing__created_at__extract_month + , subq_1.listing__created_at__extract_day + , subq_1.listing__created_at__extract_dow + , subq_1.listing__created_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.user + , subq_1.listing__user + , subq_1.country_latest + , subq_1.is_lux_latest + , subq_1.capacity_latest + , subq_1.listing__country_latest + , subq_1.listing__is_lux_latest + , subq_1.listing__capacity_latest + , subq_1.listings + , subq_1.largest_listing + , subq_1.smallest_listing 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.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 + 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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -241,16 +241,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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 LEFT 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 @@ -280,15 +280,15 @@ 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_5.user = subq_7.user - ) subq_8 - ) subq_9 + subq_3.user = subq_5.user + ) subq_6 + ) subq_7 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_10 - ) subq_11 + ) subq_8 + ) subq_9 GROUP BY - subq_11.user__home_state_latest -) subq_12 + subq_9.user__home_state_latest +) subq_10 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql index ed5fac3404..66b2f06ffb 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql @@ -9,15 +9,15 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_18.listing__is_lux_latest AS listing__is_lux_latest - , subq_18.listing__capacity_latest AS listing__capacity_latest + subq_14.listing__is_lux_latest AS listing__is_lux_latest + , subq_14.listing__capacity_latest AS listing__capacity_latest , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_18.listings AS listings + , subq_14.listings AS listings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_16.user + subq_12.user , listing__is_lux_latest , listing__capacity_latest , listings @@ -30,14 +30,14 @@ FROM ( , capacity AS listing__capacity_latest , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_12 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_18 + ) subq_14 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_18.user = users_latest_src_28000.user_id -) subq_22 + subq_14.user = users_latest_src_28000.user_id +) subq_18 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_single_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_single_categorical_dimension_pushdown__plan0.sql index 0c3cde2ebe..7c85bb04f4 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_single_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_single_categorical_dimension_pushdown__plan0.sql @@ -1,244 +1,244 @@ -- Compute Metrics via Expressions SELECT - subq_13.listing__country_latest - , subq_13.bookings + subq_11.listing__country_latest + , subq_11.bookings FROM ( -- Aggregate Measures SELECT - subq_12.listing__country_latest - , SUM(subq_12.bookings) AS bookings + subq_10.listing__country_latest + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_11.listing__country_latest - , subq_11.bookings + subq_9.listing__country_latest + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_10.booking__is_instant - , subq_10.listing__country_latest - , subq_10.bookings + subq_8.booking__is_instant + , subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_9.booking__is_instant - , subq_9.listing__country_latest - , subq_9.bookings + subq_7.booking__is_instant + , subq_7.listing__country_latest + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.listing AS listing + , subq_3.booking__is_instant AS booking__is_instant + , subq_6.country_latest AS listing__country_latest + , subq_3.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_4.listing - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.listing + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_7.listing - , subq_7.country_latest + subq_5.listing + , subq_5.country_latest 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.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 + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.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_6 - ) subq_7 - ) subq_8 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 WHERE booking__is_instant - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY - subq_12.listing__country_latest -) subq_13 + subq_10.listing__country_latest +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_single_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_single_categorical_dimension_pushdown__plan0_optimized.sql index cac7f544c4..287a6293ca 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_single_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/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_19.booking__is_instant AS booking__is_instant + subq_15.booking__is_instant AS booking__is_instant , listings_latest_src_28000.country AS listing__country_latest - , subq_19.bookings AS bookings + , subq_15.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_17 + ) subq_13 WHERE booking__is_instant - ) subq_19 + ) subq_15 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_19.listing = listings_latest_src_28000.listing_id -) subq_24 + subq_15.listing = listings_latest_src_28000.listing_id +) subq_20 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql index c939f6d0df..8595e10bfb 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -1,242 +1,242 @@ -- 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 + subq_13.metric_time__day + , CAST(subq_13.average_booking_value AS DOUBLE) / CAST(NULLIF(subq_13.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 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) AS metric_time__day + , MAX(subq_7.average_booking_value) AS average_booking_value + , MAX(subq_12.max_booking_value) AS max_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_6.metric_time__day + , subq_6.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , AVG(subq_7.average_booking_value) AS average_booking_value + subq_5.metric_time__day + , AVG(subq_5.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 + subq_4.metric_time__day + , subq_4.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.average_booking_value + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.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 + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_5.metric_time__day + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.max_booking_value + subq_11.metric_time__day + , subq_11.max_booking_value FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , MAX(subq_12.max_booking_value) AS max_booking_value + subq_10.metric_time__day + , MAX(subq_10.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 + subq_9.metric_time__day + , subq_9.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- 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_10 - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day - ) subq_13 - ) subq_14 + subq_10.metric_time__day + ) subq_11 + ) subq_12 ON - subq_9.metric_time__day = subq_14.metric_time__day + subq_7.metric_time__day = subq_12.metric_time__day GROUP BY - COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) +) subq_13 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql index 0297d39f0b..f3e1c64002 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_25.average_booking_value) AS average_booking_value - , MAX(subq_30.max_booking_value) AS max_booking_value + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) AS metric_time__day + , MAX(subq_21.average_booking_value) AS average_booking_value + , MAX(subq_26.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_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_25 + ) subq_21 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_30 + ) subq_26 ON - subq_25.metric_time__day = subq_30.metric_time__day + subq_21.metric_time__day = subq_26.metric_time__day GROUP BY - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) +) subq_27 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_multiple_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_multiple_categorical_dimension_pushdown__plan0.sql index 15d9663ea3..f9fb509b31 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_multiple_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_multiple_categorical_dimension_pushdown__plan0.sql @@ -1,186 +1,186 @@ -- Compute Metrics via Expressions SELECT - subq_12.user__home_state_latest - , subq_12.listings + subq_10.user__home_state_latest + , subq_10.listings FROM ( -- Aggregate Measures SELECT - subq_11.user__home_state_latest - , SUM(subq_11.listings) AS listings + subq_9.user__home_state_latest + , SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_10.user__home_state_latest - , subq_10.listings + subq_8.user__home_state_latest + , subq_8.listings FROM ( -- Constrain Output with WHERE SELECT - subq_9.listing__is_lux_latest - , subq_9.listing__capacity_latest - , subq_9.user__home_state_latest - , subq_9.listings + subq_7.listing__is_lux_latest + , subq_7.listing__capacity_latest + , subq_7.user__home_state_latest + , subq_7.listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_8.listing__is_lux_latest - , subq_8.listing__capacity_latest - , subq_8.user__home_state_latest - , subq_8.listings + subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.user__home_state_latest + , subq_6.listings FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.user AS user + , 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 FROM ( -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_4.user - , subq_4.listing__is_lux_latest - , subq_4.listing__capacity_latest - , subq_4.listings + subq_2.user + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings 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.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 - , 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_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.created_at__day + , subq_1.created_at__week + , subq_1.created_at__month + , subq_1.created_at__quarter + , subq_1.created_at__year + , subq_1.created_at__extract_year + , subq_1.created_at__extract_quarter + , subq_1.created_at__extract_month + , subq_1.created_at__extract_day + , subq_1.created_at__extract_dow + , subq_1.created_at__extract_doy + , subq_1.listing__ds__day + , subq_1.listing__ds__week + , subq_1.listing__ds__month + , subq_1.listing__ds__quarter + , subq_1.listing__ds__year + , subq_1.listing__ds__extract_year + , subq_1.listing__ds__extract_quarter + , subq_1.listing__ds__extract_month + , subq_1.listing__ds__extract_day + , subq_1.listing__ds__extract_dow + , subq_1.listing__ds__extract_doy + , subq_1.listing__created_at__day + , subq_1.listing__created_at__week + , subq_1.listing__created_at__month + , subq_1.listing__created_at__quarter + , subq_1.listing__created_at__year + , subq_1.listing__created_at__extract_year + , subq_1.listing__created_at__extract_quarter + , subq_1.listing__created_at__extract_month + , subq_1.listing__created_at__extract_day + , subq_1.listing__created_at__extract_dow + , subq_1.listing__created_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.user + , subq_1.listing__user + , subq_1.country_latest + , subq_1.is_lux_latest + , subq_1.capacity_latest + , subq_1.listing__country_latest + , subq_1.listing__is_lux_latest + , subq_1.listing__capacity_latest + , subq_1.listings + , subq_1.largest_listing + , subq_1.smallest_listing 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.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 + 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.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.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 ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -241,16 +241,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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 LEFT 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 @@ -280,15 +280,15 @@ 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_5.user = subq_7.user - ) subq_8 - ) subq_9 + subq_3.user = subq_5.user + ) subq_6 + ) subq_7 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_10 - ) subq_11 + ) subq_8 + ) subq_9 GROUP BY - subq_11.user__home_state_latest -) subq_12 + subq_9.user__home_state_latest +) subq_10 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql index ed5fac3404..66b2f06ffb 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql @@ -9,15 +9,15 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_18.listing__is_lux_latest AS listing__is_lux_latest - , subq_18.listing__capacity_latest AS listing__capacity_latest + subq_14.listing__is_lux_latest AS listing__is_lux_latest + , subq_14.listing__capacity_latest AS listing__capacity_latest , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_18.listings AS listings + , subq_14.listings AS listings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_16.user + subq_12.user , listing__is_lux_latest , listing__capacity_latest , listings @@ -30,14 +30,14 @@ FROM ( , capacity AS listing__capacity_latest , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_12 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_18 + ) subq_14 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_18.user = users_latest_src_28000.user_id -) subq_22 + subq_14.user = users_latest_src_28000.user_id +) subq_18 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_single_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_single_categorical_dimension_pushdown__plan0.sql index f257d9cbc3..1df100394d 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_single_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_single_categorical_dimension_pushdown__plan0.sql @@ -1,244 +1,244 @@ -- Compute Metrics via Expressions SELECT - subq_13.listing__country_latest - , subq_13.bookings + subq_11.listing__country_latest + , subq_11.bookings FROM ( -- Aggregate Measures SELECT - subq_12.listing__country_latest - , SUM(subq_12.bookings) AS bookings + subq_10.listing__country_latest + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_11.listing__country_latest - , subq_11.bookings + subq_9.listing__country_latest + , subq_9.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_10.booking__is_instant - , subq_10.listing__country_latest - , subq_10.bookings + subq_8.booking__is_instant + , subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_9.booking__is_instant - , subq_9.listing__country_latest - , subq_9.bookings + subq_7.booking__is_instant + , subq_7.listing__country_latest + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - 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 + subq_3.listing AS listing + , subq_3.booking__is_instant AS booking__is_instant + , subq_6.country_latest AS listing__country_latest + , subq_3.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_4.listing - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.listing + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_7.listing - , subq_7.country_latest + subq_5.listing + , subq_5.country_latest 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.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 + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.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_6 - ) subq_7 - ) subq_8 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 WHERE booking__is_instant - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY - subq_12.listing__country_latest -) subq_13 + subq_10.listing__country_latest +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_single_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_single_categorical_dimension_pushdown__plan0_optimized.sql index cac7f544c4..287a6293ca 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_single_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/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_19.booking__is_instant AS booking__is_instant + subq_15.booking__is_instant AS booking__is_instant , listings_latest_src_28000.country AS listing__country_latest - , subq_19.bookings AS bookings + , subq_15.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_17 + ) subq_13 WHERE booking__is_instant - ) subq_19 + ) subq_15 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_19.listing = listings_latest_src_28000.listing_id -) subq_24 + subq_15.listing = listings_latest_src_28000.listing_id +) subq_20 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql index 2fb9e4a352..855cf078d9 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day - , CAST(subq_15.booking_value_with_is_instant_constraint AS FLOAT64) / CAST(NULLIF(subq_15.booking_value, 0) AS FLOAT64) AS instant_booking_value_ratio + subq_13.metric_time__day + , CAST(subq_13.booking_value_with_is_instant_constraint AS FLOAT64) / CAST(NULLIF(subq_13.booking_value, 0) AS FLOAT64) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - 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 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) AS metric_time__day + , MAX(subq_7.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_12.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_value AS booking_value_with_is_instant_constraint + subq_6.metric_time__day + , subq_6.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_value) AS booking_value + subq_5.metric_time__day + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_value + subq_4.metric_time__day + , subq_4.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.booking_value + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.booking_value + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY metric_time__day - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.booking_value + subq_11.metric_time__day + , subq_11.booking_value FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.booking_value) AS booking_value + subq_10.metric_time__day + , SUM(subq_10.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.booking_value + subq_9.metric_time__day + , subq_9.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- 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_10 - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY metric_time__day - ) subq_13 - ) subq_14 + ) subq_11 + ) subq_12 ON - subq_9.metric_time__day = subq_14.metric_time__day + subq_7.metric_time__day = subq_12.metric_time__day GROUP BY metric_time__day -) subq_15 +) subq_13 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql index 401621a12b..d368ffbc64 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_25.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_30.booking_value) AS booking_value + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) AS metric_time__day + , MAX(subq_21.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_26.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_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_25 + ) subq_21 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 metric_time__day - ) subq_30 + ) subq_26 ON - subq_25.metric_time__day = subq_30.metric_time__day + subq_21.metric_time__day = subq_26.metric_time__day GROUP BY metric_time__day -) subq_31 +) subq_27 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0.sql index 889072cddd..64547d8b74 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,236 +1,236 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day + subq_7.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings AS delayed_bookings + subq_6.metric_time__day + , subq_6.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_5.metric_time__day + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_4.metric_time__day + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE NOT booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE NOT booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY metric_time__day - ) subq_8 -) subq_9 + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index 12d8b7ede9..e4c0b44dd5 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/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_13 + ) subq_9 WHERE NOT booking__is_instant - ) subq_15 + ) subq_11 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_19 +) subq_15 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql index 7f0864b32a..3560e89b7b 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_21.metric_time__day - , subq_21.listing__user__home_state_latest - , subq_21.bookings + subq_10.metric_time__day + , subq_10.listing__user__home_state_latest + , subq_10.bookings FROM ( -- Aggregate Measures SELECT - subq_20.metric_time__day - , subq_20.listing__user__home_state_latest - , SUM(subq_20.bookings) AS bookings + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest + , SUM(subq_9.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__home_state_latest', 'metric_time__day'] SELECT - subq_19.metric_time__day - , subq_19.listing__user__home_state_latest - , subq_19.bookings + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest + , subq_8.bookings FROM ( -- Join Standard Outputs SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.window_start__day AS listing__window_start__day - , subq_18.window_end__day AS listing__window_end__day - , subq_13.listing AS listing - , subq_18.user__home_state_latest AS listing__user__home_state_latest - , subq_13.bookings AS bookings + subq_2.metric_time__day AS metric_time__day + , subq_7.window_start__day AS listing__window_start__day + , subq_7.window_end__day AS listing__window_end__day + , subq_2.listing AS listing + , subq_7.user__home_state_latest AS listing__user__home_state_latest + , subq_2.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_12.metric_time__day - , subq_12.listing - , subq_12.bookings + subq_1.metric_time__day + , subq_1.listing + , subq_1.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.paid_at__day - , subq_11.paid_at__week - , subq_11.paid_at__month - , subq_11.paid_at__quarter - , subq_11.paid_at__year - , subq_11.paid_at__extract_year - , subq_11.paid_at__extract_quarter - , subq_11.paid_at__extract_month - , subq_11.paid_at__extract_day - , subq_11.paid_at__extract_dow - , subq_11.paid_at__extract_doy - , subq_11.booking__ds__day - , subq_11.booking__ds__week - , subq_11.booking__ds__month - , subq_11.booking__ds__quarter - , subq_11.booking__ds__year - , subq_11.booking__ds__extract_year - , subq_11.booking__ds__extract_quarter - , subq_11.booking__ds__extract_month - , subq_11.booking__ds__extract_day - , subq_11.booking__ds__extract_dow - , subq_11.booking__ds__extract_doy - , subq_11.booking__ds_partitioned__day - , subq_11.booking__ds_partitioned__week - , subq_11.booking__ds_partitioned__month - , subq_11.booking__ds_partitioned__quarter - , subq_11.booking__ds_partitioned__year - , subq_11.booking__ds_partitioned__extract_year - , subq_11.booking__ds_partitioned__extract_quarter - , subq_11.booking__ds_partitioned__extract_month - , subq_11.booking__ds_partitioned__extract_day - , subq_11.booking__ds_partitioned__extract_dow - , subq_11.booking__ds_partitioned__extract_doy - , subq_11.booking__paid_at__day - , subq_11.booking__paid_at__week - , subq_11.booking__paid_at__month - , subq_11.booking__paid_at__quarter - , subq_11.booking__paid_at__year - , subq_11.booking__paid_at__extract_year - , subq_11.booking__paid_at__extract_quarter - , subq_11.booking__paid_at__extract_month - , subq_11.booking__paid_at__extract_day - , subq_11.booking__paid_at__extract_dow - , subq_11.booking__paid_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.guest - , subq_11.host - , subq_11.user - , subq_11.booking__listing - , subq_11.booking__guest - , subq_11.booking__host - , subq_11.booking__user - , subq_11.is_instant - , subq_11.booking__is_instant - , subq_11.bookings - , subq_11.instant_bookings - , subq_11.booking_value - , subq_11.bookers - , subq_11.average_booking_value + 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.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,84 +211,84 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_17.window_start__day - , subq_17.window_end__day - , subq_17.listing - , subq_17.user__home_state_latest + subq_6.window_start__day + , subq_6.window_end__day + , subq_6.listing + , subq_6.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_14.window_start__day AS window_start__day - , subq_14.window_start__week AS window_start__week - , subq_14.window_start__month AS window_start__month - , subq_14.window_start__quarter AS window_start__quarter - , subq_14.window_start__year AS window_start__year - , subq_14.window_start__extract_year AS window_start__extract_year - , subq_14.window_start__extract_quarter AS window_start__extract_quarter - , subq_14.window_start__extract_month AS window_start__extract_month - , subq_14.window_start__extract_day AS window_start__extract_day - , subq_14.window_start__extract_dow AS window_start__extract_dow - , subq_14.window_start__extract_doy AS window_start__extract_doy - , subq_14.window_end__day AS window_end__day - , subq_14.window_end__week AS window_end__week - , subq_14.window_end__month AS window_end__month - , subq_14.window_end__quarter AS window_end__quarter - , subq_14.window_end__year AS window_end__year - , subq_14.window_end__extract_year AS window_end__extract_year - , subq_14.window_end__extract_quarter AS window_end__extract_quarter - , subq_14.window_end__extract_month AS window_end__extract_month - , subq_14.window_end__extract_day AS window_end__extract_day - , subq_14.window_end__extract_dow AS window_end__extract_dow - , subq_14.window_end__extract_doy AS window_end__extract_doy - , subq_14.listing__window_start__day AS listing__window_start__day - , subq_14.listing__window_start__week AS listing__window_start__week - , subq_14.listing__window_start__month AS listing__window_start__month - , subq_14.listing__window_start__quarter AS listing__window_start__quarter - , subq_14.listing__window_start__year AS listing__window_start__year - , subq_14.listing__window_start__extract_year AS listing__window_start__extract_year - , subq_14.listing__window_start__extract_quarter AS listing__window_start__extract_quarter - , subq_14.listing__window_start__extract_month AS listing__window_start__extract_month - , subq_14.listing__window_start__extract_day AS listing__window_start__extract_day - , subq_14.listing__window_start__extract_dow AS listing__window_start__extract_dow - , subq_14.listing__window_start__extract_doy AS listing__window_start__extract_doy - , subq_14.listing__window_end__day AS listing__window_end__day - , subq_14.listing__window_end__week AS listing__window_end__week - , subq_14.listing__window_end__month AS listing__window_end__month - , subq_14.listing__window_end__quarter AS listing__window_end__quarter - , subq_14.listing__window_end__year AS listing__window_end__year - , subq_14.listing__window_end__extract_year AS listing__window_end__extract_year - , subq_14.listing__window_end__extract_quarter AS listing__window_end__extract_quarter - , subq_14.listing__window_end__extract_month AS listing__window_end__extract_month - , subq_14.listing__window_end__extract_day AS listing__window_end__extract_day - , subq_14.listing__window_end__extract_dow AS listing__window_end__extract_dow - , subq_14.listing__window_end__extract_doy AS listing__window_end__extract_doy - , subq_16.ds__day AS user__ds__day - , subq_16.ds__week AS user__ds__week - , subq_16.ds__month AS user__ds__month - , subq_16.ds__quarter AS user__ds__quarter - , subq_16.ds__year AS user__ds__year - , subq_16.ds__extract_year AS user__ds__extract_year - , subq_16.ds__extract_quarter AS user__ds__extract_quarter - , subq_16.ds__extract_month AS user__ds__extract_month - , subq_16.ds__extract_day AS user__ds__extract_day - , subq_16.ds__extract_dow AS user__ds__extract_dow - , subq_16.ds__extract_doy AS user__ds__extract_doy - , subq_14.listing AS listing - , subq_14.user AS user - , subq_14.listing__user AS listing__user - , subq_14.country AS country - , subq_14.is_lux AS is_lux - , subq_14.capacity AS capacity - , subq_14.listing__country AS listing__country - , subq_14.listing__is_lux AS listing__is_lux - , subq_14.listing__capacity AS listing__capacity - , subq_16.home_state_latest AS user__home_state_latest + subq_3.window_start__day AS window_start__day + , subq_3.window_start__week AS window_start__week + , subq_3.window_start__month AS window_start__month + , subq_3.window_start__quarter AS window_start__quarter + , subq_3.window_start__year AS window_start__year + , subq_3.window_start__extract_year AS window_start__extract_year + , subq_3.window_start__extract_quarter AS window_start__extract_quarter + , subq_3.window_start__extract_month AS window_start__extract_month + , subq_3.window_start__extract_day AS window_start__extract_day + , subq_3.window_start__extract_dow AS window_start__extract_dow + , subq_3.window_start__extract_doy AS window_start__extract_doy + , subq_3.window_end__day AS window_end__day + , subq_3.window_end__week AS window_end__week + , subq_3.window_end__month AS window_end__month + , subq_3.window_end__quarter AS window_end__quarter + , subq_3.window_end__year AS window_end__year + , subq_3.window_end__extract_year AS window_end__extract_year + , subq_3.window_end__extract_quarter AS window_end__extract_quarter + , subq_3.window_end__extract_month AS window_end__extract_month + , subq_3.window_end__extract_day AS window_end__extract_day + , subq_3.window_end__extract_dow AS window_end__extract_dow + , subq_3.window_end__extract_doy AS window_end__extract_doy + , subq_3.listing__window_start__day AS listing__window_start__day + , subq_3.listing__window_start__week AS listing__window_start__week + , subq_3.listing__window_start__month AS listing__window_start__month + , subq_3.listing__window_start__quarter AS listing__window_start__quarter + , subq_3.listing__window_start__year AS listing__window_start__year + , subq_3.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_3.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_3.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_3.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_3.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_3.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_3.listing__window_end__day AS listing__window_end__day + , subq_3.listing__window_end__week AS listing__window_end__week + , subq_3.listing__window_end__month AS listing__window_end__month + , subq_3.listing__window_end__quarter AS listing__window_end__quarter + , subq_3.listing__window_end__year AS listing__window_end__year + , subq_3.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_3.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_3.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_3.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_3.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_3.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_5.ds__day AS user__ds__day + , subq_5.ds__week AS user__ds__week + , subq_5.ds__month AS user__ds__month + , subq_5.ds__quarter AS user__ds__quarter + , subq_5.ds__year AS user__ds__year + , subq_5.ds__extract_year AS user__ds__extract_year + , subq_5.ds__extract_quarter AS user__ds__extract_quarter + , subq_5.ds__extract_month AS user__ds__extract_month + , subq_5.ds__extract_day AS user__ds__extract_day + , subq_5.ds__extract_dow AS user__ds__extract_dow + , subq_5.ds__extract_doy AS user__ds__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country AS country + , subq_3.is_lux AS is_lux + , subq_3.capacity AS capacity + , subq_3.listing__country AS listing__country + , subq_3.listing__is_lux AS listing__is_lux + , subq_3.listing__capacity AS listing__capacity + , subq_5.home_state_latest AS user__home_state_latest FROM ( -- Read Elements From Semantic Model 'listings' SELECT @@ -346,7 +346,7 @@ FROM ( , listings_src_26000.user_id AS user , listings_src_26000.user_id AS listing__user FROM ***************************.dim_listings listings_src_26000 - ) subq_14 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,31 +376,31 @@ FROM ( -- 'user', -- ] SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.user__ds__day - , subq_15.user__ds__week - , subq_15.user__ds__month - , subq_15.user__ds__quarter - , subq_15.user__ds__year - , subq_15.user__ds__extract_year - , subq_15.user__ds__extract_quarter - , subq_15.user__ds__extract_month - , subq_15.user__ds__extract_day - , subq_15.user__ds__extract_dow - , subq_15.user__ds__extract_doy - , subq_15.user - , subq_15.home_state_latest - , subq_15.user__home_state_latest + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.user__ds__day + , subq_4.user__ds__week + , subq_4.user__ds__month + , subq_4.user__ds__quarter + , subq_4.user__ds__year + , subq_4.user__ds__extract_year + , subq_4.user__ds__extract_quarter + , subq_4.user__ds__extract_month + , subq_4.user__ds__extract_day + , subq_4.user__ds__extract_dow + , subq_4.user__ds__extract_doy + , subq_4.user + , subq_4.home_state_latest + , subq_4.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -430,29 +430,29 @@ FROM ( , users_latest_src_26000.home_state_latest AS user__home_state_latest , users_latest_src_26000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_26000 - ) subq_15 - ) subq_16 + ) subq_4 + ) subq_5 ON - subq_14.user = subq_16.user - ) subq_17 - ) subq_18 + subq_3.user = subq_5.user + ) subq_6 + ) subq_7 ON ( - subq_13.listing = subq_18.listing + subq_2.listing = subq_7.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_2.metric_time__day >= subq_7.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_2.metric_time__day < subq_7.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_7.window_end__day IS NULL ) ) ) - ) subq_19 - ) subq_20 + ) subq_8 + ) subq_9 GROUP BY metric_time__day , listing__user__home_state_latest -) subq_21 +) subq_10 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql index 535a1d2ebf..84ba528526 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_35.metric_time__day AS metric_time__day - , subq_40.user__home_state_latest AS listing__user__home_state_latest - , SUM(subq_35.bookings) AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_18.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,7 +15,7 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_35 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] @@ -29,18 +29,18 @@ LEFT OUTER JOIN ( ***************************.dim_users_latest users_latest_src_26000 ON listings_src_26000.user_id = users_latest_src_26000.user_id -) subq_40 +) subq_18 ON ( - subq_35.listing = subq_40.listing + subq_13.listing = subq_18.listing ) AND ( ( - subq_35.metric_time__day >= subq_40.window_start__day + subq_13.metric_time__day >= subq_18.window_start__day ) AND ( ( - subq_35.metric_time__day < subq_40.window_end__day + subq_13.metric_time__day < subq_18.window_end__day ) OR ( - subq_40.window_end__day IS NULL + subq_18.window_end__day IS NULL ) ) ) diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql index 226137f009..344de3883f 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__lux_listing__is_confirmed_lux - , subq_13.bookings + subq_10.metric_time__day + , subq_10.listing__lux_listing__is_confirmed_lux + , subq_10.bookings FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.listing__lux_listing__is_confirmed_lux - , SUM(subq_12.bookings) AS bookings + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux + , SUM(subq_9.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__lux_listing__is_confirmed_lux', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listing__lux_listing__is_confirmed_lux - , subq_11.bookings + subq_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux + , subq_8.bookings FROM ( -- Join Standard Outputs SELECT - subq_5.metric_time__day AS metric_time__day - , subq_10.lux_listing__window_start__day AS listing__lux_listing__window_start__day - , subq_10.lux_listing__window_end__day AS listing__lux_listing__window_end__day - , subq_5.listing AS listing - , subq_10.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , subq_5.bookings AS bookings + subq_2.metric_time__day AS metric_time__day + , subq_7.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_7.lux_listing__window_end__day AS listing__lux_listing__window_end__day + , subq_2.listing AS listing + , subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_2.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_4.metric_time__day - , subq_4.listing - , subq_4.bookings + subq_1.metric_time__day + , subq_1.listing + , subq_1.bookings 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_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.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.listing - , subq_3.guest - , subq_3.host - , subq_3.user - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.booking__user - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.bookers - , subq_3.average_booking_value + 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.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,45 +211,45 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - subq_9.lux_listing__window_start__day - , subq_9.lux_listing__window_end__day - , subq_9.listing - , subq_9.lux_listing__is_confirmed_lux + subq_6.lux_listing__window_start__day + , subq_6.lux_listing__window_end__day + , subq_6.listing + , subq_6.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_8.window_start__day AS lux_listing__window_start__day - , subq_8.window_start__week AS lux_listing__window_start__week - , subq_8.window_start__month AS lux_listing__window_start__month - , subq_8.window_start__quarter AS lux_listing__window_start__quarter - , subq_8.window_start__year AS lux_listing__window_start__year - , subq_8.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_8.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_8.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_8.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_8.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_8.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_8.window_end__day AS lux_listing__window_end__day - , subq_8.window_end__week AS lux_listing__window_end__week - , subq_8.window_end__month AS lux_listing__window_end__month - , subq_8.window_end__quarter AS lux_listing__window_end__quarter - , subq_8.window_end__year AS lux_listing__window_end__year - , subq_8.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_8.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_8.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_8.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_8.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_8.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_6.listing AS listing - , subq_6.lux_listing AS lux_listing - , subq_6.listing__lux_listing AS listing__lux_listing - , subq_8.is_confirmed_lux AS lux_listing__is_confirmed_lux + subq_5.window_start__day AS lux_listing__window_start__day + , subq_5.window_start__week AS lux_listing__window_start__week + , subq_5.window_start__month AS lux_listing__window_start__month + , subq_5.window_start__quarter AS lux_listing__window_start__quarter + , subq_5.window_start__year AS lux_listing__window_start__year + , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_5.window_end__day AS lux_listing__window_end__day + , subq_5.window_end__week AS lux_listing__window_end__week + , subq_5.window_end__month AS lux_listing__window_end__month + , subq_5.window_end__quarter AS lux_listing__window_end__quarter + , subq_5.window_end__year AS lux_listing__window_end__year + , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_3.listing AS listing + , subq_3.lux_listing AS lux_listing + , subq_3.listing__lux_listing AS listing__lux_listing + , subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -257,7 +257,7 @@ FROM ( , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 - ) subq_6 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,53 +309,53 @@ FROM ( -- 'lux_listing', -- ] SELECT - subq_7.window_start__day - , subq_7.window_start__week - , subq_7.window_start__month - , subq_7.window_start__quarter - , subq_7.window_start__year - , subq_7.window_start__extract_year - , subq_7.window_start__extract_quarter - , subq_7.window_start__extract_month - , subq_7.window_start__extract_day - , subq_7.window_start__extract_dow - , subq_7.window_start__extract_doy - , subq_7.window_end__day - , subq_7.window_end__week - , subq_7.window_end__month - , subq_7.window_end__quarter - , subq_7.window_end__year - , subq_7.window_end__extract_year - , subq_7.window_end__extract_quarter - , subq_7.window_end__extract_month - , subq_7.window_end__extract_day - , subq_7.window_end__extract_dow - , subq_7.window_end__extract_doy - , subq_7.lux_listing__window_start__day - , subq_7.lux_listing__window_start__week - , subq_7.lux_listing__window_start__month - , subq_7.lux_listing__window_start__quarter - , subq_7.lux_listing__window_start__year - , subq_7.lux_listing__window_start__extract_year - , subq_7.lux_listing__window_start__extract_quarter - , subq_7.lux_listing__window_start__extract_month - , subq_7.lux_listing__window_start__extract_day - , subq_7.lux_listing__window_start__extract_dow - , subq_7.lux_listing__window_start__extract_doy - , subq_7.lux_listing__window_end__day - , subq_7.lux_listing__window_end__week - , subq_7.lux_listing__window_end__month - , subq_7.lux_listing__window_end__quarter - , subq_7.lux_listing__window_end__year - , subq_7.lux_listing__window_end__extract_year - , subq_7.lux_listing__window_end__extract_quarter - , subq_7.lux_listing__window_end__extract_month - , subq_7.lux_listing__window_end__extract_day - , subq_7.lux_listing__window_end__extract_dow - , subq_7.lux_listing__window_end__extract_doy - , subq_7.lux_listing - , subq_7.is_confirmed_lux - , subq_7.lux_listing__is_confirmed_lux + subq_4.window_start__day + , subq_4.window_start__week + , subq_4.window_start__month + , subq_4.window_start__quarter + , subq_4.window_start__year + , subq_4.window_start__extract_year + , subq_4.window_start__extract_quarter + , subq_4.window_start__extract_month + , subq_4.window_start__extract_day + , subq_4.window_start__extract_dow + , subq_4.window_start__extract_doy + , subq_4.window_end__day + , subq_4.window_end__week + , subq_4.window_end__month + , subq_4.window_end__quarter + , subq_4.window_end__year + , subq_4.window_end__extract_year + , subq_4.window_end__extract_quarter + , subq_4.window_end__extract_month + , subq_4.window_end__extract_day + , subq_4.window_end__extract_dow + , subq_4.window_end__extract_doy + , subq_4.lux_listing__window_start__day + , subq_4.lux_listing__window_start__week + , subq_4.lux_listing__window_start__month + , subq_4.lux_listing__window_start__quarter + , subq_4.lux_listing__window_start__year + , subq_4.lux_listing__window_start__extract_year + , subq_4.lux_listing__window_start__extract_quarter + , subq_4.lux_listing__window_start__extract_month + , subq_4.lux_listing__window_start__extract_day + , subq_4.lux_listing__window_start__extract_dow + , subq_4.lux_listing__window_start__extract_doy + , subq_4.lux_listing__window_end__day + , subq_4.lux_listing__window_end__week + , subq_4.lux_listing__window_end__month + , subq_4.lux_listing__window_end__quarter + , subq_4.lux_listing__window_end__year + , subq_4.lux_listing__window_end__extract_year + , subq_4.lux_listing__window_end__extract_quarter + , subq_4.lux_listing__window_end__extract_month + , subq_4.lux_listing__window_end__extract_day + , subq_4.lux_listing__window_end__extract_dow + , subq_4.lux_listing__window_end__extract_doy + , subq_4.lux_listing + , subq_4.is_confirmed_lux + , subq_4.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT @@ -407,29 +407,29 @@ FROM ( , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux , lux_listings_src_26000.lux_listing_id AS lux_listing FROM ***************************.dim_lux_listings lux_listings_src_26000 - ) subq_7 - ) subq_8 + ) subq_4 + ) subq_5 ON - subq_6.lux_listing = subq_8.lux_listing - ) subq_9 - ) subq_10 + subq_3.lux_listing = subq_5.lux_listing + ) subq_6 + ) subq_7 ON ( - subq_5.listing = subq_10.listing + subq_2.listing = subq_7.listing ) AND ( ( - subq_5.metric_time__day >= subq_10.lux_listing__window_start__day + subq_2.metric_time__day >= subq_7.lux_listing__window_start__day ) AND ( ( - subq_5.metric_time__day < subq_10.lux_listing__window_end__day + subq_2.metric_time__day < subq_7.lux_listing__window_end__day ) OR ( - subq_10.lux_listing__window_end__day IS NULL + subq_7.lux_listing__window_end__day IS NULL ) ) ) - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 GROUP BY metric_time__day , listing__lux_listing__is_confirmed_lux -) subq_13 +) subq_10 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql index a289335698..b3653bd063 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_19.metric_time__day AS metric_time__day - , subq_24.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , SUM(subq_19.bookings) AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_18.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,7 +15,7 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_19 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] @@ -29,18 +29,18 @@ LEFT OUTER JOIN ( ***************************.dim_lux_listings lux_listings_src_26000 ON lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id -) subq_24 +) subq_18 ON ( - subq_19.listing = subq_24.listing + subq_13.listing = subq_18.listing ) AND ( ( - subq_19.metric_time__day >= subq_24.lux_listing__window_start__day + subq_13.metric_time__day >= subq_18.lux_listing__window_start__day ) AND ( ( - subq_19.metric_time__day < subq_24.lux_listing__window_end__day + subq_13.metric_time__day < subq_18.lux_listing__window_end__day ) OR ( - subq_24.lux_listing__window_end__day IS NULL + subq_18.lux_listing__window_end__day IS NULL ) ) ) diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql index f5dab65f4f..9b356cf368 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql @@ -1,93 +1,93 @@ -- Compute Metrics via Expressions SELECT - subq_17.account_id__customer_id__customer_name - , subq_17.txn_count + subq_12.account_id__customer_id__customer_name + , subq_12.txn_count FROM ( -- Aggregate Measures SELECT - subq_16.account_id__customer_id__customer_name - , SUM(subq_16.txn_count) AS txn_count + subq_11.account_id__customer_id__customer_name + , SUM(subq_11.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_15.account_id__customer_id__customer_name - , subq_15.txn_count + subq_10.account_id__customer_id__customer_name + , subq_10.txn_count FROM ( -- Join Standard Outputs SELECT - subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_14.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_7.account_id AS account_id - , subq_14.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_7.txn_count AS txn_count + subq_2.ds_partitioned__day AS ds_partitioned__day + , subq_9.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_2.account_id AS account_id + , subq_9.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_2.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_6.ds_partitioned__day - , subq_6.account_id - , subq_6.txn_count + subq_1.ds_partitioned__day + , subq_1.account_id + , subq_1.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.account_id__ds_partitioned__day - , subq_5.account_id__ds_partitioned__week - , subq_5.account_id__ds_partitioned__month - , subq_5.account_id__ds_partitioned__quarter - , subq_5.account_id__ds_partitioned__year - , subq_5.account_id__ds_partitioned__extract_year - , subq_5.account_id__ds_partitioned__extract_quarter - , subq_5.account_id__ds_partitioned__extract_month - , subq_5.account_id__ds_partitioned__extract_day - , subq_5.account_id__ds_partitioned__extract_dow - , subq_5.account_id__ds_partitioned__extract_doy - , subq_5.account_id__ds__day - , subq_5.account_id__ds__week - , subq_5.account_id__ds__month - , subq_5.account_id__ds__quarter - , subq_5.account_id__ds__year - , subq_5.account_id__ds__extract_year - , subq_5.account_id__ds__extract_quarter - , subq_5.account_id__ds__extract_month - , subq_5.account_id__ds__extract_day - , subq_5.account_id__ds__extract_dow - , subq_5.account_id__ds__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.account_id - , subq_5.account_month - , subq_5.account_id__account_month - , subq_5.txn_count + 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.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.account_id__ds_partitioned__day + , subq_0.account_id__ds_partitioned__week + , subq_0.account_id__ds_partitioned__month + , subq_0.account_id__ds_partitioned__quarter + , subq_0.account_id__ds_partitioned__year + , subq_0.account_id__ds_partitioned__extract_year + , subq_0.account_id__ds_partitioned__extract_quarter + , subq_0.account_id__ds_partitioned__extract_month + , subq_0.account_id__ds_partitioned__extract_day + , subq_0.account_id__ds_partitioned__extract_dow + , subq_0.account_id__ds_partitioned__extract_doy + , subq_0.account_id__ds__day + , subq_0.account_id__ds__week + , subq_0.account_id__ds__month + , subq_0.account_id__ds__quarter + , subq_0.account_id__ds__year + , subq_0.account_id__ds__extract_year + , subq_0.account_id__ds__extract_quarter + , subq_0.account_id__ds__extract_month + , subq_0.account_id__ds__extract_day + , subq_0.account_id__ds__extract_dow + , subq_0.account_id__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.account_id + , subq_0.account_month + , subq_0.account_id__account_month + , subq_0.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -140,151 +140,151 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_13.ds_partitioned__day - , subq_13.account_id - , subq_13.customer_id__customer_name + subq_8.ds_partitioned__day + , subq_8.account_id + , subq_8.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_9.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_9.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_9.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_9.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_9.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_9.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_9.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_9.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_9.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_9.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_9.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_9.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_9.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_9.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_9.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_9.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_9.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_9.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_9.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_9.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_9.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_9.metric_time__day AS metric_time__day - , subq_9.metric_time__week AS metric_time__week - , subq_9.metric_time__month AS metric_time__month - , subq_9.metric_time__quarter AS metric_time__quarter - , subq_9.metric_time__year AS metric_time__year - , subq_9.metric_time__extract_year AS metric_time__extract_year - , subq_9.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_9.metric_time__extract_month AS metric_time__extract_month - , subq_9.metric_time__extract_day AS metric_time__extract_day - , subq_9.metric_time__extract_dow AS metric_time__extract_dow - , subq_9.metric_time__extract_doy AS metric_time__extract_doy - , subq_12.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_12.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_12.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_12.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_12.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_12.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_12.metric_time__day AS customer_id__metric_time__day - , subq_12.metric_time__week AS customer_id__metric_time__week - , subq_12.metric_time__month AS customer_id__metric_time__month - , subq_12.metric_time__quarter AS customer_id__metric_time__quarter - , subq_12.metric_time__year AS customer_id__metric_time__year - , subq_12.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_12.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_12.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_12.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_12.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_12.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_9.account_id AS account_id - , subq_9.customer_id AS customer_id - , subq_9.account_id__customer_id AS account_id__customer_id - , subq_9.bridge_account__account_id AS bridge_account__account_id - , subq_9.bridge_account__customer_id AS bridge_account__customer_id - , subq_9.extra_dim AS extra_dim - , subq_9.account_id__extra_dim AS account_id__extra_dim - , subq_9.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_12.customer_name AS customer_id__customer_name - , subq_12.customer_atomic_weight AS customer_id__customer_atomic_weight - , subq_9.account_customer_combos AS account_customer_combos + subq_4.ds_partitioned__day AS ds_partitioned__day + , subq_4.ds_partitioned__week AS ds_partitioned__week + , subq_4.ds_partitioned__month AS ds_partitioned__month + , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_4.ds_partitioned__year AS ds_partitioned__year + , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_4.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_4.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_4.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_4.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_4.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_4.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_4.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_4.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_4.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_4.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_4.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_4.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_4.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_4.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_4.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_4.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_4.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_4.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_4.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_4.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_4.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_4.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_4.metric_time__day AS metric_time__day + , subq_4.metric_time__week AS metric_time__week + , subq_4.metric_time__month AS metric_time__month + , subq_4.metric_time__quarter AS metric_time__quarter + , subq_4.metric_time__year AS metric_time__year + , subq_4.metric_time__extract_year AS metric_time__extract_year + , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_4.metric_time__extract_month AS metric_time__extract_month + , subq_4.metric_time__extract_day AS metric_time__extract_day + , subq_4.metric_time__extract_dow AS metric_time__extract_dow + , subq_4.metric_time__extract_doy AS metric_time__extract_doy + , subq_7.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_7.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_7.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_7.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_7.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_7.metric_time__day AS customer_id__metric_time__day + , subq_7.metric_time__week AS customer_id__metric_time__week + , subq_7.metric_time__month AS customer_id__metric_time__month + , subq_7.metric_time__quarter AS customer_id__metric_time__quarter + , subq_7.metric_time__year AS customer_id__metric_time__year + , subq_7.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_7.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_7.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_7.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_7.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_7.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_4.account_id AS account_id + , subq_4.customer_id AS customer_id + , subq_4.account_id__customer_id AS account_id__customer_id + , subq_4.bridge_account__account_id AS bridge_account__account_id + , subq_4.bridge_account__customer_id AS bridge_account__customer_id + , subq_4.extra_dim AS extra_dim + , subq_4.account_id__extra_dim AS account_id__extra_dim + , subq_4.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_7.customer_name AS customer_id__customer_name + , subq_7.customer_atomic_weight AS customer_id__customer_atomic_weight + , subq_4.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.account_id__ds_partitioned__day - , subq_8.account_id__ds_partitioned__week - , subq_8.account_id__ds_partitioned__month - , subq_8.account_id__ds_partitioned__quarter - , subq_8.account_id__ds_partitioned__year - , subq_8.account_id__ds_partitioned__extract_year - , subq_8.account_id__ds_partitioned__extract_quarter - , subq_8.account_id__ds_partitioned__extract_month - , subq_8.account_id__ds_partitioned__extract_day - , subq_8.account_id__ds_partitioned__extract_dow - , subq_8.account_id__ds_partitioned__extract_doy - , subq_8.bridge_account__ds_partitioned__day - , subq_8.bridge_account__ds_partitioned__week - , subq_8.bridge_account__ds_partitioned__month - , subq_8.bridge_account__ds_partitioned__quarter - , subq_8.bridge_account__ds_partitioned__year - , subq_8.bridge_account__ds_partitioned__extract_year - , subq_8.bridge_account__ds_partitioned__extract_quarter - , subq_8.bridge_account__ds_partitioned__extract_month - , subq_8.bridge_account__ds_partitioned__extract_day - , subq_8.bridge_account__ds_partitioned__extract_dow - , subq_8.bridge_account__ds_partitioned__extract_doy - , subq_8.ds_partitioned__day AS metric_time__day - , subq_8.ds_partitioned__week AS metric_time__week - , subq_8.ds_partitioned__month AS metric_time__month - , subq_8.ds_partitioned__quarter AS metric_time__quarter - , subq_8.ds_partitioned__year AS metric_time__year - , subq_8.ds_partitioned__extract_year AS metric_time__extract_year - , subq_8.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_8.ds_partitioned__extract_month AS metric_time__extract_month - , subq_8.ds_partitioned__extract_day AS metric_time__extract_day - , subq_8.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_8.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_8.account_id - , subq_8.customer_id - , subq_8.account_id__customer_id - , subq_8.bridge_account__account_id - , subq_8.bridge_account__customer_id - , subq_8.extra_dim - , subq_8.account_id__extra_dim - , subq_8.bridge_account__extra_dim - , subq_8.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_3.account_id__ds_partitioned__week + , subq_3.account_id__ds_partitioned__month + , subq_3.account_id__ds_partitioned__quarter + , subq_3.account_id__ds_partitioned__year + , subq_3.account_id__ds_partitioned__extract_year + , subq_3.account_id__ds_partitioned__extract_quarter + , subq_3.account_id__ds_partitioned__extract_month + , subq_3.account_id__ds_partitioned__extract_day + , subq_3.account_id__ds_partitioned__extract_dow + , subq_3.account_id__ds_partitioned__extract_doy + , subq_3.bridge_account__ds_partitioned__day + , subq_3.bridge_account__ds_partitioned__week + , subq_3.bridge_account__ds_partitioned__month + , subq_3.bridge_account__ds_partitioned__quarter + , subq_3.bridge_account__ds_partitioned__year + , subq_3.bridge_account__ds_partitioned__extract_year + , subq_3.bridge_account__ds_partitioned__extract_quarter + , subq_3.bridge_account__ds_partitioned__extract_month + , subq_3.bridge_account__ds_partitioned__extract_day + , subq_3.bridge_account__ds_partitioned__extract_dow + , subq_3.bridge_account__ds_partitioned__extract_doy + , subq_3.ds_partitioned__day AS metric_time__day + , subq_3.ds_partitioned__week AS metric_time__week + , subq_3.ds_partitioned__month AS metric_time__month + , subq_3.ds_partitioned__quarter AS metric_time__quarter + , subq_3.ds_partitioned__year AS metric_time__year + , subq_3.ds_partitioned__extract_year AS metric_time__extract_year + , subq_3.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_3.ds_partitioned__extract_month AS metric_time__extract_month + , subq_3.ds_partitioned__extract_day AS metric_time__extract_day + , subq_3.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_3.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_3.account_id + , subq_3.customer_id + , subq_3.account_id__customer_id + , subq_3.bridge_account__account_id + , subq_3.bridge_account__customer_id + , subq_3.extra_dim + , subq_3.account_id__extra_dim + , subq_3.bridge_account__extra_dim + , subq_3.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -331,8 +331,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -375,86 +375,86 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.customer_id__ds_partitioned__day - , subq_11.customer_id__ds_partitioned__week - , subq_11.customer_id__ds_partitioned__month - , subq_11.customer_id__ds_partitioned__quarter - , subq_11.customer_id__ds_partitioned__year - , subq_11.customer_id__ds_partitioned__extract_year - , subq_11.customer_id__ds_partitioned__extract_quarter - , subq_11.customer_id__ds_partitioned__extract_month - , subq_11.customer_id__ds_partitioned__extract_day - , subq_11.customer_id__ds_partitioned__extract_dow - , subq_11.customer_id__ds_partitioned__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.customer_id - , subq_11.customer_name - , subq_11.customer_atomic_weight - , subq_11.customer_id__customer_name - , subq_11.customer_id__customer_atomic_weight + 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.customer_id__ds_partitioned__day + , subq_6.customer_id__ds_partitioned__week + , subq_6.customer_id__ds_partitioned__month + , subq_6.customer_id__ds_partitioned__quarter + , subq_6.customer_id__ds_partitioned__year + , subq_6.customer_id__ds_partitioned__extract_year + , subq_6.customer_id__ds_partitioned__extract_quarter + , subq_6.customer_id__ds_partitioned__extract_month + , subq_6.customer_id__ds_partitioned__extract_day + , subq_6.customer_id__ds_partitioned__extract_dow + , subq_6.customer_id__ds_partitioned__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.customer_id + , subq_6.customer_name + , subq_6.customer_atomic_weight + , subq_6.customer_id__customer_name + , subq_6.customer_id__customer_atomic_weight FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - 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.customer_id__ds_partitioned__day - , subq_10.customer_id__ds_partitioned__week - , subq_10.customer_id__ds_partitioned__month - , subq_10.customer_id__ds_partitioned__quarter - , subq_10.customer_id__ds_partitioned__year - , subq_10.customer_id__ds_partitioned__extract_year - , subq_10.customer_id__ds_partitioned__extract_quarter - , subq_10.customer_id__ds_partitioned__extract_month - , subq_10.customer_id__ds_partitioned__extract_day - , subq_10.customer_id__ds_partitioned__extract_dow - , subq_10.customer_id__ds_partitioned__extract_doy - , subq_10.ds_partitioned__day AS metric_time__day - , subq_10.ds_partitioned__week AS metric_time__week - , subq_10.ds_partitioned__month AS metric_time__month - , subq_10.ds_partitioned__quarter AS metric_time__quarter - , subq_10.ds_partitioned__year AS metric_time__year - , subq_10.ds_partitioned__extract_year AS metric_time__extract_year - , subq_10.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_10.ds_partitioned__extract_month AS metric_time__extract_month - , subq_10.ds_partitioned__extract_day AS metric_time__extract_day - , subq_10.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_10.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_10.customer_id - , subq_10.customer_name - , subq_10.customer_atomic_weight - , subq_10.customer_id__customer_name - , subq_10.customer_id__customer_atomic_weight - , subq_10.customers + subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.customer_id__ds_partitioned__day + , subq_5.customer_id__ds_partitioned__week + , subq_5.customer_id__ds_partitioned__month + , subq_5.customer_id__ds_partitioned__quarter + , subq_5.customer_id__ds_partitioned__year + , subq_5.customer_id__ds_partitioned__extract_year + , subq_5.customer_id__ds_partitioned__extract_quarter + , subq_5.customer_id__ds_partitioned__extract_month + , subq_5.customer_id__ds_partitioned__extract_day + , subq_5.customer_id__ds_partitioned__extract_dow + , subq_5.customer_id__ds_partitioned__extract_doy + , subq_5.ds_partitioned__day AS metric_time__day + , subq_5.ds_partitioned__week AS metric_time__week + , subq_5.ds_partitioned__month AS metric_time__month + , subq_5.ds_partitioned__quarter AS metric_time__quarter + , subq_5.ds_partitioned__year AS metric_time__year + , subq_5.ds_partitioned__extract_year AS metric_time__extract_year + , subq_5.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_5.ds_partitioned__extract_month AS metric_time__extract_month + , subq_5.ds_partitioned__extract_day AS metric_time__extract_day + , subq_5.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_5.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_5.customer_id + , subq_5.customer_name + , subq_5.customer_atomic_weight + , subq_5.customer_id__customer_name + , subq_5.customer_id__customer_atomic_weight + , subq_5.customers FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT @@ -487,25 +487,25 @@ FROM ( , EXTRACT(dayofyear FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy , customer_table_src_22000.customer_id FROM ***************************.customer_table customer_table_src_22000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_5 + ) subq_6 + ) subq_7 ON ( - subq_9.customer_id = subq_12.customer_id + subq_4.customer_id = subq_7.customer_id ) AND ( - subq_9.ds_partitioned__day = subq_12.ds_partitioned__day + subq_4.ds_partitioned__day = subq_7.ds_partitioned__day ) - ) subq_13 - ) subq_14 + ) subq_8 + ) subq_9 ON ( - subq_7.account_id = subq_14.account_id + subq_2.account_id = subq_9.account_id ) AND ( - subq_7.ds_partitioned__day = subq_14.ds_partitioned__day + subq_2.ds_partitioned__day = subq_9.ds_partitioned__day ) - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 GROUP BY account_id__customer_id__customer_name -) subq_17 +) subq_12 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql index 1b65544879..6effa4e774 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_32.customer_id__customer_name AS account_id__customer_id__customer_name + subq_22.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -22,12 +22,12 @@ LEFT OUTER JOIN ( ) AND ( DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, day) = DATETIME_TRUNC(customer_table_src_22000.ds_partitioned, day) ) -) subq_32 +) subq_22 ON ( - account_month_txns_src_22000.account_id = subq_32.account_id + account_month_txns_src_22000.account_id = subq_22.account_id ) AND ( - DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, day) = subq_32.ds_partitioned__day + DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, day) = subq_22.ds_partitioned__day ) GROUP BY account_id__customer_id__customer_name diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0.sql index 5745eb82cc..50dda82c59 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0.sql @@ -1,221 +1,221 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_9.bookings) AS bookings - , MAX(subq_15.listings) AS listings + MAX(subq_5.bookings) AS bookings + , MAX(subq_11.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.bookings + subq_4.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_7.bookings) AS bookings + SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_6.bookings + subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -308,165 +308,165 @@ 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_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_6 - ) subq_7 - ) subq_8 -) subq_9 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_2 + ) subq_3 + ) subq_4 +) subq_5 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.listings + subq_10.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_13.listings) AS listings + SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_12.listings + subq_8.listings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.smallest_listing + 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.created_at__day + , subq_7.created_at__week + , subq_7.created_at__month + , subq_7.created_at__quarter + , subq_7.created_at__year + , subq_7.created_at__extract_year + , subq_7.created_at__extract_quarter + , subq_7.created_at__extract_month + , subq_7.created_at__extract_day + , subq_7.created_at__extract_dow + , subq_7.created_at__extract_doy + , subq_7.listing__ds__day + , subq_7.listing__ds__week + , subq_7.listing__ds__month + , subq_7.listing__ds__quarter + , subq_7.listing__ds__year + , subq_7.listing__ds__extract_year + , subq_7.listing__ds__extract_quarter + , subq_7.listing__ds__extract_month + , subq_7.listing__ds__extract_day + , subq_7.listing__ds__extract_dow + , subq_7.listing__ds__extract_doy + , subq_7.listing__created_at__day + , subq_7.listing__created_at__week + , subq_7.listing__created_at__month + , subq_7.listing__created_at__quarter + , subq_7.listing__created_at__year + , subq_7.listing__created_at__extract_year + , subq_7.listing__created_at__extract_quarter + , subq_7.listing__created_at__extract_month + , subq_7.listing__created_at__extract_day + , subq_7.listing__created_at__extract_dow + , subq_7.listing__created_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.user + , subq_7.listing__user + , subq_7.country_latest + , subq_7.is_lux_latest + , subq_7.capacity_latest + , subq_7.listing__country_latest + , subq_7.listing__is_lux_latest + , subq_7.listing__capacity_latest + , subq_7.listings + , subq_7.largest_listing + , subq_7.smallest_listing 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 @@ -527,10 +527,10 @@ CROSS JOIN ( , 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 - WHERE subq_11.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_12 - ) subq_13 - ) subq_14 -) subq_15 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_8 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 055a8557d9..1105f00c5d 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_25.bookings) AS bookings - , MAX(subq_31.listings) AS listings + MAX(subq_17.bookings) AS bookings + , MAX(subq_23.listings) AS listings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -13,7 +13,7 @@ FROM ( SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATETIME_TRUNC(ds, day) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_25 +) subq_17 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -25,4 +25,4 @@ CROSS JOIN ( SUM(1) AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 WHERE DATETIME_TRUNC(created_at, day) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_31 +) subq_23 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql index 98239358a2..accc8e18b1 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - 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 + subq_13.metric_time__day + , CAST(subq_13.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_13.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - 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 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) AS metric_time__day + , MAX(subq_7.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_12.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_value AS booking_value_with_is_instant_constraint + subq_6.metric_time__day + , subq_6.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_value) AS booking_value + subq_5.metric_time__day + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_value + subq_4.metric_time__day + , subq_4.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.booking_value + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.booking_value + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_5.metric_time__day + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.booking_value + subq_11.metric_time__day + , subq_11.booking_value FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.booking_value) AS booking_value + subq_10.metric_time__day + , SUM(subq_10.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.booking_value + subq_9.metric_time__day + , subq_9.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- 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_10 - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day - ) subq_13 - ) subq_14 + subq_10.metric_time__day + ) subq_11 + ) subq_12 ON - subq_9.metric_time__day = subq_14.metric_time__day + subq_7.metric_time__day = subq_12.metric_time__day GROUP BY - COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) +) subq_13 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql index a795130ca2..bd85051779 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_25.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_30.booking_value) AS booking_value + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) AS metric_time__day + , MAX(subq_21.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_26.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_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_25 + ) subq_21 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_30 + ) subq_26 ON - subq_25.metric_time__day = subq_30.metric_time__day + subq_21.metric_time__day = subq_26.metric_time__day GROUP BY - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) +) subq_27 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0.sql index 54cd5f4827..400b3f4e4c 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,236 +1,236 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day + subq_7.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings AS delayed_bookings + subq_6.metric_time__day + , subq_6.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_5.metric_time__day + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_4.metric_time__day + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE NOT booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE NOT booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_5.metric_time__day + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index 4076d55e53..e23b3a548f 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/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_13 + ) subq_9 WHERE NOT booking__is_instant - ) subq_15 + ) subq_11 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_19 +) subq_15 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql index 462f8a5059..c9ccb81485 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_21.metric_time__day - , subq_21.listing__user__home_state_latest - , subq_21.bookings + subq_10.metric_time__day + , subq_10.listing__user__home_state_latest + , subq_10.bookings FROM ( -- Aggregate Measures SELECT - subq_20.metric_time__day - , subq_20.listing__user__home_state_latest - , SUM(subq_20.bookings) AS bookings + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest + , SUM(subq_9.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__home_state_latest', 'metric_time__day'] SELECT - subq_19.metric_time__day - , subq_19.listing__user__home_state_latest - , subq_19.bookings + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest + , subq_8.bookings FROM ( -- Join Standard Outputs SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.window_start__day AS listing__window_start__day - , subq_18.window_end__day AS listing__window_end__day - , subq_13.listing AS listing - , subq_18.user__home_state_latest AS listing__user__home_state_latest - , subq_13.bookings AS bookings + subq_2.metric_time__day AS metric_time__day + , subq_7.window_start__day AS listing__window_start__day + , subq_7.window_end__day AS listing__window_end__day + , subq_2.listing AS listing + , subq_7.user__home_state_latest AS listing__user__home_state_latest + , subq_2.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_12.metric_time__day - , subq_12.listing - , subq_12.bookings + subq_1.metric_time__day + , subq_1.listing + , subq_1.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.paid_at__day - , subq_11.paid_at__week - , subq_11.paid_at__month - , subq_11.paid_at__quarter - , subq_11.paid_at__year - , subq_11.paid_at__extract_year - , subq_11.paid_at__extract_quarter - , subq_11.paid_at__extract_month - , subq_11.paid_at__extract_day - , subq_11.paid_at__extract_dow - , subq_11.paid_at__extract_doy - , subq_11.booking__ds__day - , subq_11.booking__ds__week - , subq_11.booking__ds__month - , subq_11.booking__ds__quarter - , subq_11.booking__ds__year - , subq_11.booking__ds__extract_year - , subq_11.booking__ds__extract_quarter - , subq_11.booking__ds__extract_month - , subq_11.booking__ds__extract_day - , subq_11.booking__ds__extract_dow - , subq_11.booking__ds__extract_doy - , subq_11.booking__ds_partitioned__day - , subq_11.booking__ds_partitioned__week - , subq_11.booking__ds_partitioned__month - , subq_11.booking__ds_partitioned__quarter - , subq_11.booking__ds_partitioned__year - , subq_11.booking__ds_partitioned__extract_year - , subq_11.booking__ds_partitioned__extract_quarter - , subq_11.booking__ds_partitioned__extract_month - , subq_11.booking__ds_partitioned__extract_day - , subq_11.booking__ds_partitioned__extract_dow - , subq_11.booking__ds_partitioned__extract_doy - , subq_11.booking__paid_at__day - , subq_11.booking__paid_at__week - , subq_11.booking__paid_at__month - , subq_11.booking__paid_at__quarter - , subq_11.booking__paid_at__year - , subq_11.booking__paid_at__extract_year - , subq_11.booking__paid_at__extract_quarter - , subq_11.booking__paid_at__extract_month - , subq_11.booking__paid_at__extract_day - , subq_11.booking__paid_at__extract_dow - , subq_11.booking__paid_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.guest - , subq_11.host - , subq_11.user - , subq_11.booking__listing - , subq_11.booking__guest - , subq_11.booking__host - , subq_11.booking__user - , subq_11.is_instant - , subq_11.booking__is_instant - , subq_11.bookings - , subq_11.instant_bookings - , subq_11.booking_value - , subq_11.bookers - , subq_11.average_booking_value + 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.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,84 +211,84 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_17.window_start__day - , subq_17.window_end__day - , subq_17.listing - , subq_17.user__home_state_latest + subq_6.window_start__day + , subq_6.window_end__day + , subq_6.listing + , subq_6.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_14.window_start__day AS window_start__day - , subq_14.window_start__week AS window_start__week - , subq_14.window_start__month AS window_start__month - , subq_14.window_start__quarter AS window_start__quarter - , subq_14.window_start__year AS window_start__year - , subq_14.window_start__extract_year AS window_start__extract_year - , subq_14.window_start__extract_quarter AS window_start__extract_quarter - , subq_14.window_start__extract_month AS window_start__extract_month - , subq_14.window_start__extract_day AS window_start__extract_day - , subq_14.window_start__extract_dow AS window_start__extract_dow - , subq_14.window_start__extract_doy AS window_start__extract_doy - , subq_14.window_end__day AS window_end__day - , subq_14.window_end__week AS window_end__week - , subq_14.window_end__month AS window_end__month - , subq_14.window_end__quarter AS window_end__quarter - , subq_14.window_end__year AS window_end__year - , subq_14.window_end__extract_year AS window_end__extract_year - , subq_14.window_end__extract_quarter AS window_end__extract_quarter - , subq_14.window_end__extract_month AS window_end__extract_month - , subq_14.window_end__extract_day AS window_end__extract_day - , subq_14.window_end__extract_dow AS window_end__extract_dow - , subq_14.window_end__extract_doy AS window_end__extract_doy - , subq_14.listing__window_start__day AS listing__window_start__day - , subq_14.listing__window_start__week AS listing__window_start__week - , subq_14.listing__window_start__month AS listing__window_start__month - , subq_14.listing__window_start__quarter AS listing__window_start__quarter - , subq_14.listing__window_start__year AS listing__window_start__year - , subq_14.listing__window_start__extract_year AS listing__window_start__extract_year - , subq_14.listing__window_start__extract_quarter AS listing__window_start__extract_quarter - , subq_14.listing__window_start__extract_month AS listing__window_start__extract_month - , subq_14.listing__window_start__extract_day AS listing__window_start__extract_day - , subq_14.listing__window_start__extract_dow AS listing__window_start__extract_dow - , subq_14.listing__window_start__extract_doy AS listing__window_start__extract_doy - , subq_14.listing__window_end__day AS listing__window_end__day - , subq_14.listing__window_end__week AS listing__window_end__week - , subq_14.listing__window_end__month AS listing__window_end__month - , subq_14.listing__window_end__quarter AS listing__window_end__quarter - , subq_14.listing__window_end__year AS listing__window_end__year - , subq_14.listing__window_end__extract_year AS listing__window_end__extract_year - , subq_14.listing__window_end__extract_quarter AS listing__window_end__extract_quarter - , subq_14.listing__window_end__extract_month AS listing__window_end__extract_month - , subq_14.listing__window_end__extract_day AS listing__window_end__extract_day - , subq_14.listing__window_end__extract_dow AS listing__window_end__extract_dow - , subq_14.listing__window_end__extract_doy AS listing__window_end__extract_doy - , subq_16.ds__day AS user__ds__day - , subq_16.ds__week AS user__ds__week - , subq_16.ds__month AS user__ds__month - , subq_16.ds__quarter AS user__ds__quarter - , subq_16.ds__year AS user__ds__year - , subq_16.ds__extract_year AS user__ds__extract_year - , subq_16.ds__extract_quarter AS user__ds__extract_quarter - , subq_16.ds__extract_month AS user__ds__extract_month - , subq_16.ds__extract_day AS user__ds__extract_day - , subq_16.ds__extract_dow AS user__ds__extract_dow - , subq_16.ds__extract_doy AS user__ds__extract_doy - , subq_14.listing AS listing - , subq_14.user AS user - , subq_14.listing__user AS listing__user - , subq_14.country AS country - , subq_14.is_lux AS is_lux - , subq_14.capacity AS capacity - , subq_14.listing__country AS listing__country - , subq_14.listing__is_lux AS listing__is_lux - , subq_14.listing__capacity AS listing__capacity - , subq_16.home_state_latest AS user__home_state_latest + subq_3.window_start__day AS window_start__day + , subq_3.window_start__week AS window_start__week + , subq_3.window_start__month AS window_start__month + , subq_3.window_start__quarter AS window_start__quarter + , subq_3.window_start__year AS window_start__year + , subq_3.window_start__extract_year AS window_start__extract_year + , subq_3.window_start__extract_quarter AS window_start__extract_quarter + , subq_3.window_start__extract_month AS window_start__extract_month + , subq_3.window_start__extract_day AS window_start__extract_day + , subq_3.window_start__extract_dow AS window_start__extract_dow + , subq_3.window_start__extract_doy AS window_start__extract_doy + , subq_3.window_end__day AS window_end__day + , subq_3.window_end__week AS window_end__week + , subq_3.window_end__month AS window_end__month + , subq_3.window_end__quarter AS window_end__quarter + , subq_3.window_end__year AS window_end__year + , subq_3.window_end__extract_year AS window_end__extract_year + , subq_3.window_end__extract_quarter AS window_end__extract_quarter + , subq_3.window_end__extract_month AS window_end__extract_month + , subq_3.window_end__extract_day AS window_end__extract_day + , subq_3.window_end__extract_dow AS window_end__extract_dow + , subq_3.window_end__extract_doy AS window_end__extract_doy + , subq_3.listing__window_start__day AS listing__window_start__day + , subq_3.listing__window_start__week AS listing__window_start__week + , subq_3.listing__window_start__month AS listing__window_start__month + , subq_3.listing__window_start__quarter AS listing__window_start__quarter + , subq_3.listing__window_start__year AS listing__window_start__year + , subq_3.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_3.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_3.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_3.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_3.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_3.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_3.listing__window_end__day AS listing__window_end__day + , subq_3.listing__window_end__week AS listing__window_end__week + , subq_3.listing__window_end__month AS listing__window_end__month + , subq_3.listing__window_end__quarter AS listing__window_end__quarter + , subq_3.listing__window_end__year AS listing__window_end__year + , subq_3.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_3.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_3.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_3.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_3.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_3.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_5.ds__day AS user__ds__day + , subq_5.ds__week AS user__ds__week + , subq_5.ds__month AS user__ds__month + , subq_5.ds__quarter AS user__ds__quarter + , subq_5.ds__year AS user__ds__year + , subq_5.ds__extract_year AS user__ds__extract_year + , subq_5.ds__extract_quarter AS user__ds__extract_quarter + , subq_5.ds__extract_month AS user__ds__extract_month + , subq_5.ds__extract_day AS user__ds__extract_day + , subq_5.ds__extract_dow AS user__ds__extract_dow + , subq_5.ds__extract_doy AS user__ds__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country AS country + , subq_3.is_lux AS is_lux + , subq_3.capacity AS capacity + , subq_3.listing__country AS listing__country + , subq_3.listing__is_lux AS listing__is_lux + , subq_3.listing__capacity AS listing__capacity + , subq_5.home_state_latest AS user__home_state_latest FROM ( -- Read Elements From Semantic Model 'listings' SELECT @@ -346,7 +346,7 @@ FROM ( , listings_src_26000.user_id AS user , listings_src_26000.user_id AS listing__user FROM ***************************.dim_listings listings_src_26000 - ) subq_14 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,31 +376,31 @@ FROM ( -- 'user', -- ] SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.user__ds__day - , subq_15.user__ds__week - , subq_15.user__ds__month - , subq_15.user__ds__quarter - , subq_15.user__ds__year - , subq_15.user__ds__extract_year - , subq_15.user__ds__extract_quarter - , subq_15.user__ds__extract_month - , subq_15.user__ds__extract_day - , subq_15.user__ds__extract_dow - , subq_15.user__ds__extract_doy - , subq_15.user - , subq_15.home_state_latest - , subq_15.user__home_state_latest + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.user__ds__day + , subq_4.user__ds__week + , subq_4.user__ds__month + , subq_4.user__ds__quarter + , subq_4.user__ds__year + , subq_4.user__ds__extract_year + , subq_4.user__ds__extract_quarter + , subq_4.user__ds__extract_month + , subq_4.user__ds__extract_day + , subq_4.user__ds__extract_dow + , subq_4.user__ds__extract_doy + , subq_4.user + , subq_4.home_state_latest + , subq_4.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -430,29 +430,29 @@ FROM ( , users_latest_src_26000.home_state_latest AS user__home_state_latest , users_latest_src_26000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_26000 - ) subq_15 - ) subq_16 + ) subq_4 + ) subq_5 ON - subq_14.user = subq_16.user - ) subq_17 - ) subq_18 + subq_3.user = subq_5.user + ) subq_6 + ) subq_7 ON ( - subq_13.listing = subq_18.listing + subq_2.listing = subq_7.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_2.metric_time__day >= subq_7.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_2.metric_time__day < subq_7.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_7.window_end__day IS NULL ) ) ) - ) subq_19 - ) subq_20 + ) subq_8 + ) subq_9 GROUP BY - subq_20.metric_time__day - , subq_20.listing__user__home_state_latest -) subq_21 + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest +) subq_10 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql index ad6481bf38..43c459ada2 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_35.metric_time__day AS metric_time__day - , subq_40.user__home_state_latest AS listing__user__home_state_latest - , SUM(subq_35.bookings) AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_18.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,7 +15,7 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_35 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] @@ -29,21 +29,21 @@ LEFT OUTER JOIN ( ***************************.dim_users_latest users_latest_src_26000 ON listings_src_26000.user_id = users_latest_src_26000.user_id -) subq_40 +) subq_18 ON ( - subq_35.listing = subq_40.listing + subq_13.listing = subq_18.listing ) AND ( ( - subq_35.metric_time__day >= subq_40.window_start__day + subq_13.metric_time__day >= subq_18.window_start__day ) AND ( ( - subq_35.metric_time__day < subq_40.window_end__day + subq_13.metric_time__day < subq_18.window_end__day ) OR ( - subq_40.window_end__day IS NULL + subq_18.window_end__day IS NULL ) ) ) GROUP BY - subq_35.metric_time__day - , subq_40.user__home_state_latest + subq_13.metric_time__day + , subq_18.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql index 2bc93f0f96..ed2197c59b 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__lux_listing__is_confirmed_lux - , subq_13.bookings + subq_10.metric_time__day + , subq_10.listing__lux_listing__is_confirmed_lux + , subq_10.bookings FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.listing__lux_listing__is_confirmed_lux - , SUM(subq_12.bookings) AS bookings + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux + , SUM(subq_9.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__lux_listing__is_confirmed_lux', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listing__lux_listing__is_confirmed_lux - , subq_11.bookings + subq_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux + , subq_8.bookings FROM ( -- Join Standard Outputs SELECT - subq_5.metric_time__day AS metric_time__day - , subq_10.lux_listing__window_start__day AS listing__lux_listing__window_start__day - , subq_10.lux_listing__window_end__day AS listing__lux_listing__window_end__day - , subq_5.listing AS listing - , subq_10.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , subq_5.bookings AS bookings + subq_2.metric_time__day AS metric_time__day + , subq_7.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_7.lux_listing__window_end__day AS listing__lux_listing__window_end__day + , subq_2.listing AS listing + , subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_2.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_4.metric_time__day - , subq_4.listing - , subq_4.bookings + subq_1.metric_time__day + , subq_1.listing + , subq_1.bookings 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_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.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.listing - , subq_3.guest - , subq_3.host - , subq_3.user - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.booking__user - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.bookers - , subq_3.average_booking_value + 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.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,45 +211,45 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - subq_9.lux_listing__window_start__day - , subq_9.lux_listing__window_end__day - , subq_9.listing - , subq_9.lux_listing__is_confirmed_lux + subq_6.lux_listing__window_start__day + , subq_6.lux_listing__window_end__day + , subq_6.listing + , subq_6.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_8.window_start__day AS lux_listing__window_start__day - , subq_8.window_start__week AS lux_listing__window_start__week - , subq_8.window_start__month AS lux_listing__window_start__month - , subq_8.window_start__quarter AS lux_listing__window_start__quarter - , subq_8.window_start__year AS lux_listing__window_start__year - , subq_8.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_8.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_8.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_8.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_8.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_8.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_8.window_end__day AS lux_listing__window_end__day - , subq_8.window_end__week AS lux_listing__window_end__week - , subq_8.window_end__month AS lux_listing__window_end__month - , subq_8.window_end__quarter AS lux_listing__window_end__quarter - , subq_8.window_end__year AS lux_listing__window_end__year - , subq_8.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_8.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_8.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_8.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_8.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_8.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_6.listing AS listing - , subq_6.lux_listing AS lux_listing - , subq_6.listing__lux_listing AS listing__lux_listing - , subq_8.is_confirmed_lux AS lux_listing__is_confirmed_lux + subq_5.window_start__day AS lux_listing__window_start__day + , subq_5.window_start__week AS lux_listing__window_start__week + , subq_5.window_start__month AS lux_listing__window_start__month + , subq_5.window_start__quarter AS lux_listing__window_start__quarter + , subq_5.window_start__year AS lux_listing__window_start__year + , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_5.window_end__day AS lux_listing__window_end__day + , subq_5.window_end__week AS lux_listing__window_end__week + , subq_5.window_end__month AS lux_listing__window_end__month + , subq_5.window_end__quarter AS lux_listing__window_end__quarter + , subq_5.window_end__year AS lux_listing__window_end__year + , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_3.listing AS listing + , subq_3.lux_listing AS lux_listing + , subq_3.listing__lux_listing AS listing__lux_listing + , subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -257,7 +257,7 @@ FROM ( , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 - ) subq_6 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,53 +309,53 @@ FROM ( -- 'lux_listing', -- ] SELECT - subq_7.window_start__day - , subq_7.window_start__week - , subq_7.window_start__month - , subq_7.window_start__quarter - , subq_7.window_start__year - , subq_7.window_start__extract_year - , subq_7.window_start__extract_quarter - , subq_7.window_start__extract_month - , subq_7.window_start__extract_day - , subq_7.window_start__extract_dow - , subq_7.window_start__extract_doy - , subq_7.window_end__day - , subq_7.window_end__week - , subq_7.window_end__month - , subq_7.window_end__quarter - , subq_7.window_end__year - , subq_7.window_end__extract_year - , subq_7.window_end__extract_quarter - , subq_7.window_end__extract_month - , subq_7.window_end__extract_day - , subq_7.window_end__extract_dow - , subq_7.window_end__extract_doy - , subq_7.lux_listing__window_start__day - , subq_7.lux_listing__window_start__week - , subq_7.lux_listing__window_start__month - , subq_7.lux_listing__window_start__quarter - , subq_7.lux_listing__window_start__year - , subq_7.lux_listing__window_start__extract_year - , subq_7.lux_listing__window_start__extract_quarter - , subq_7.lux_listing__window_start__extract_month - , subq_7.lux_listing__window_start__extract_day - , subq_7.lux_listing__window_start__extract_dow - , subq_7.lux_listing__window_start__extract_doy - , subq_7.lux_listing__window_end__day - , subq_7.lux_listing__window_end__week - , subq_7.lux_listing__window_end__month - , subq_7.lux_listing__window_end__quarter - , subq_7.lux_listing__window_end__year - , subq_7.lux_listing__window_end__extract_year - , subq_7.lux_listing__window_end__extract_quarter - , subq_7.lux_listing__window_end__extract_month - , subq_7.lux_listing__window_end__extract_day - , subq_7.lux_listing__window_end__extract_dow - , subq_7.lux_listing__window_end__extract_doy - , subq_7.lux_listing - , subq_7.is_confirmed_lux - , subq_7.lux_listing__is_confirmed_lux + subq_4.window_start__day + , subq_4.window_start__week + , subq_4.window_start__month + , subq_4.window_start__quarter + , subq_4.window_start__year + , subq_4.window_start__extract_year + , subq_4.window_start__extract_quarter + , subq_4.window_start__extract_month + , subq_4.window_start__extract_day + , subq_4.window_start__extract_dow + , subq_4.window_start__extract_doy + , subq_4.window_end__day + , subq_4.window_end__week + , subq_4.window_end__month + , subq_4.window_end__quarter + , subq_4.window_end__year + , subq_4.window_end__extract_year + , subq_4.window_end__extract_quarter + , subq_4.window_end__extract_month + , subq_4.window_end__extract_day + , subq_4.window_end__extract_dow + , subq_4.window_end__extract_doy + , subq_4.lux_listing__window_start__day + , subq_4.lux_listing__window_start__week + , subq_4.lux_listing__window_start__month + , subq_4.lux_listing__window_start__quarter + , subq_4.lux_listing__window_start__year + , subq_4.lux_listing__window_start__extract_year + , subq_4.lux_listing__window_start__extract_quarter + , subq_4.lux_listing__window_start__extract_month + , subq_4.lux_listing__window_start__extract_day + , subq_4.lux_listing__window_start__extract_dow + , subq_4.lux_listing__window_start__extract_doy + , subq_4.lux_listing__window_end__day + , subq_4.lux_listing__window_end__week + , subq_4.lux_listing__window_end__month + , subq_4.lux_listing__window_end__quarter + , subq_4.lux_listing__window_end__year + , subq_4.lux_listing__window_end__extract_year + , subq_4.lux_listing__window_end__extract_quarter + , subq_4.lux_listing__window_end__extract_month + , subq_4.lux_listing__window_end__extract_day + , subq_4.lux_listing__window_end__extract_dow + , subq_4.lux_listing__window_end__extract_doy + , subq_4.lux_listing + , subq_4.is_confirmed_lux + , subq_4.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT @@ -407,29 +407,29 @@ FROM ( , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux , lux_listings_src_26000.lux_listing_id AS lux_listing FROM ***************************.dim_lux_listings lux_listings_src_26000 - ) subq_7 - ) subq_8 + ) subq_4 + ) subq_5 ON - subq_6.lux_listing = subq_8.lux_listing - ) subq_9 - ) subq_10 + subq_3.lux_listing = subq_5.lux_listing + ) subq_6 + ) subq_7 ON ( - subq_5.listing = subq_10.listing + subq_2.listing = subq_7.listing ) AND ( ( - subq_5.metric_time__day >= subq_10.lux_listing__window_start__day + subq_2.metric_time__day >= subq_7.lux_listing__window_start__day ) AND ( ( - subq_5.metric_time__day < subq_10.lux_listing__window_end__day + subq_2.metric_time__day < subq_7.lux_listing__window_end__day ) OR ( - subq_10.lux_listing__window_end__day IS NULL + subq_7.lux_listing__window_end__day IS NULL ) ) ) - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 GROUP BY - subq_12.metric_time__day - , subq_12.listing__lux_listing__is_confirmed_lux -) subq_13 + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux +) subq_10 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql index eaaa8aa132..d0d6125e14 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_19.metric_time__day AS metric_time__day - , subq_24.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , SUM(subq_19.bookings) AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_18.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,7 +15,7 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_19 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] @@ -29,21 +29,21 @@ LEFT OUTER JOIN ( ***************************.dim_lux_listings lux_listings_src_26000 ON lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id -) subq_24 +) subq_18 ON ( - subq_19.listing = subq_24.listing + subq_13.listing = subq_18.listing ) AND ( ( - subq_19.metric_time__day >= subq_24.lux_listing__window_start__day + subq_13.metric_time__day >= subq_18.lux_listing__window_start__day ) AND ( ( - subq_19.metric_time__day < subq_24.lux_listing__window_end__day + subq_13.metric_time__day < subq_18.lux_listing__window_end__day ) OR ( - subq_24.lux_listing__window_end__day IS NULL + subq_18.lux_listing__window_end__day IS NULL ) ) ) GROUP BY - subq_19.metric_time__day - , subq_24.lux_listing__is_confirmed_lux + subq_13.metric_time__day + , subq_18.lux_listing__is_confirmed_lux diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql index 2ecc96050f..28a6ba862c 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql @@ -1,93 +1,93 @@ -- Compute Metrics via Expressions SELECT - subq_17.account_id__customer_id__customer_name - , subq_17.txn_count + subq_12.account_id__customer_id__customer_name + , subq_12.txn_count FROM ( -- Aggregate Measures SELECT - subq_16.account_id__customer_id__customer_name - , SUM(subq_16.txn_count) AS txn_count + subq_11.account_id__customer_id__customer_name + , SUM(subq_11.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_15.account_id__customer_id__customer_name - , subq_15.txn_count + subq_10.account_id__customer_id__customer_name + , subq_10.txn_count FROM ( -- Join Standard Outputs SELECT - subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_14.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_7.account_id AS account_id - , subq_14.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_7.txn_count AS txn_count + subq_2.ds_partitioned__day AS ds_partitioned__day + , subq_9.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_2.account_id AS account_id + , subq_9.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_2.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_6.ds_partitioned__day - , subq_6.account_id - , subq_6.txn_count + subq_1.ds_partitioned__day + , subq_1.account_id + , subq_1.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.account_id__ds_partitioned__day - , subq_5.account_id__ds_partitioned__week - , subq_5.account_id__ds_partitioned__month - , subq_5.account_id__ds_partitioned__quarter - , subq_5.account_id__ds_partitioned__year - , subq_5.account_id__ds_partitioned__extract_year - , subq_5.account_id__ds_partitioned__extract_quarter - , subq_5.account_id__ds_partitioned__extract_month - , subq_5.account_id__ds_partitioned__extract_day - , subq_5.account_id__ds_partitioned__extract_dow - , subq_5.account_id__ds_partitioned__extract_doy - , subq_5.account_id__ds__day - , subq_5.account_id__ds__week - , subq_5.account_id__ds__month - , subq_5.account_id__ds__quarter - , subq_5.account_id__ds__year - , subq_5.account_id__ds__extract_year - , subq_5.account_id__ds__extract_quarter - , subq_5.account_id__ds__extract_month - , subq_5.account_id__ds__extract_day - , subq_5.account_id__ds__extract_dow - , subq_5.account_id__ds__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.account_id - , subq_5.account_month - , subq_5.account_id__account_month - , subq_5.txn_count + 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.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.account_id__ds_partitioned__day + , subq_0.account_id__ds_partitioned__week + , subq_0.account_id__ds_partitioned__month + , subq_0.account_id__ds_partitioned__quarter + , subq_0.account_id__ds_partitioned__year + , subq_0.account_id__ds_partitioned__extract_year + , subq_0.account_id__ds_partitioned__extract_quarter + , subq_0.account_id__ds_partitioned__extract_month + , subq_0.account_id__ds_partitioned__extract_day + , subq_0.account_id__ds_partitioned__extract_dow + , subq_0.account_id__ds_partitioned__extract_doy + , subq_0.account_id__ds__day + , subq_0.account_id__ds__week + , subq_0.account_id__ds__month + , subq_0.account_id__ds__quarter + , subq_0.account_id__ds__year + , subq_0.account_id__ds__extract_year + , subq_0.account_id__ds__extract_quarter + , subq_0.account_id__ds__extract_month + , subq_0.account_id__ds__extract_day + , subq_0.account_id__ds__extract_dow + , subq_0.account_id__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.account_id + , subq_0.account_month + , subq_0.account_id__account_month + , subq_0.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -140,151 +140,151 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_13.ds_partitioned__day - , subq_13.account_id - , subq_13.customer_id__customer_name + subq_8.ds_partitioned__day + , subq_8.account_id + , subq_8.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_9.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_9.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_9.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_9.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_9.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_9.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_9.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_9.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_9.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_9.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_9.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_9.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_9.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_9.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_9.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_9.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_9.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_9.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_9.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_9.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_9.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_9.metric_time__day AS metric_time__day - , subq_9.metric_time__week AS metric_time__week - , subq_9.metric_time__month AS metric_time__month - , subq_9.metric_time__quarter AS metric_time__quarter - , subq_9.metric_time__year AS metric_time__year - , subq_9.metric_time__extract_year AS metric_time__extract_year - , subq_9.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_9.metric_time__extract_month AS metric_time__extract_month - , subq_9.metric_time__extract_day AS metric_time__extract_day - , subq_9.metric_time__extract_dow AS metric_time__extract_dow - , subq_9.metric_time__extract_doy AS metric_time__extract_doy - , subq_12.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_12.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_12.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_12.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_12.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_12.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_12.metric_time__day AS customer_id__metric_time__day - , subq_12.metric_time__week AS customer_id__metric_time__week - , subq_12.metric_time__month AS customer_id__metric_time__month - , subq_12.metric_time__quarter AS customer_id__metric_time__quarter - , subq_12.metric_time__year AS customer_id__metric_time__year - , subq_12.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_12.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_12.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_12.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_12.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_12.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_9.account_id AS account_id - , subq_9.customer_id AS customer_id - , subq_9.account_id__customer_id AS account_id__customer_id - , subq_9.bridge_account__account_id AS bridge_account__account_id - , subq_9.bridge_account__customer_id AS bridge_account__customer_id - , subq_9.extra_dim AS extra_dim - , subq_9.account_id__extra_dim AS account_id__extra_dim - , subq_9.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_12.customer_name AS customer_id__customer_name - , subq_12.customer_atomic_weight AS customer_id__customer_atomic_weight - , subq_9.account_customer_combos AS account_customer_combos + subq_4.ds_partitioned__day AS ds_partitioned__day + , subq_4.ds_partitioned__week AS ds_partitioned__week + , subq_4.ds_partitioned__month AS ds_partitioned__month + , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_4.ds_partitioned__year AS ds_partitioned__year + , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_4.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_4.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_4.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_4.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_4.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_4.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_4.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_4.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_4.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_4.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_4.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_4.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_4.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_4.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_4.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_4.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_4.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_4.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_4.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_4.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_4.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_4.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_4.metric_time__day AS metric_time__day + , subq_4.metric_time__week AS metric_time__week + , subq_4.metric_time__month AS metric_time__month + , subq_4.metric_time__quarter AS metric_time__quarter + , subq_4.metric_time__year AS metric_time__year + , subq_4.metric_time__extract_year AS metric_time__extract_year + , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_4.metric_time__extract_month AS metric_time__extract_month + , subq_4.metric_time__extract_day AS metric_time__extract_day + , subq_4.metric_time__extract_dow AS metric_time__extract_dow + , subq_4.metric_time__extract_doy AS metric_time__extract_doy + , subq_7.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_7.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_7.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_7.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_7.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_7.metric_time__day AS customer_id__metric_time__day + , subq_7.metric_time__week AS customer_id__metric_time__week + , subq_7.metric_time__month AS customer_id__metric_time__month + , subq_7.metric_time__quarter AS customer_id__metric_time__quarter + , subq_7.metric_time__year AS customer_id__metric_time__year + , subq_7.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_7.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_7.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_7.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_7.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_7.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_4.account_id AS account_id + , subq_4.customer_id AS customer_id + , subq_4.account_id__customer_id AS account_id__customer_id + , subq_4.bridge_account__account_id AS bridge_account__account_id + , subq_4.bridge_account__customer_id AS bridge_account__customer_id + , subq_4.extra_dim AS extra_dim + , subq_4.account_id__extra_dim AS account_id__extra_dim + , subq_4.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_7.customer_name AS customer_id__customer_name + , subq_7.customer_atomic_weight AS customer_id__customer_atomic_weight + , subq_4.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.account_id__ds_partitioned__day - , subq_8.account_id__ds_partitioned__week - , subq_8.account_id__ds_partitioned__month - , subq_8.account_id__ds_partitioned__quarter - , subq_8.account_id__ds_partitioned__year - , subq_8.account_id__ds_partitioned__extract_year - , subq_8.account_id__ds_partitioned__extract_quarter - , subq_8.account_id__ds_partitioned__extract_month - , subq_8.account_id__ds_partitioned__extract_day - , subq_8.account_id__ds_partitioned__extract_dow - , subq_8.account_id__ds_partitioned__extract_doy - , subq_8.bridge_account__ds_partitioned__day - , subq_8.bridge_account__ds_partitioned__week - , subq_8.bridge_account__ds_partitioned__month - , subq_8.bridge_account__ds_partitioned__quarter - , subq_8.bridge_account__ds_partitioned__year - , subq_8.bridge_account__ds_partitioned__extract_year - , subq_8.bridge_account__ds_partitioned__extract_quarter - , subq_8.bridge_account__ds_partitioned__extract_month - , subq_8.bridge_account__ds_partitioned__extract_day - , subq_8.bridge_account__ds_partitioned__extract_dow - , subq_8.bridge_account__ds_partitioned__extract_doy - , subq_8.ds_partitioned__day AS metric_time__day - , subq_8.ds_partitioned__week AS metric_time__week - , subq_8.ds_partitioned__month AS metric_time__month - , subq_8.ds_partitioned__quarter AS metric_time__quarter - , subq_8.ds_partitioned__year AS metric_time__year - , subq_8.ds_partitioned__extract_year AS metric_time__extract_year - , subq_8.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_8.ds_partitioned__extract_month AS metric_time__extract_month - , subq_8.ds_partitioned__extract_day AS metric_time__extract_day - , subq_8.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_8.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_8.account_id - , subq_8.customer_id - , subq_8.account_id__customer_id - , subq_8.bridge_account__account_id - , subq_8.bridge_account__customer_id - , subq_8.extra_dim - , subq_8.account_id__extra_dim - , subq_8.bridge_account__extra_dim - , subq_8.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_3.account_id__ds_partitioned__week + , subq_3.account_id__ds_partitioned__month + , subq_3.account_id__ds_partitioned__quarter + , subq_3.account_id__ds_partitioned__year + , subq_3.account_id__ds_partitioned__extract_year + , subq_3.account_id__ds_partitioned__extract_quarter + , subq_3.account_id__ds_partitioned__extract_month + , subq_3.account_id__ds_partitioned__extract_day + , subq_3.account_id__ds_partitioned__extract_dow + , subq_3.account_id__ds_partitioned__extract_doy + , subq_3.bridge_account__ds_partitioned__day + , subq_3.bridge_account__ds_partitioned__week + , subq_3.bridge_account__ds_partitioned__month + , subq_3.bridge_account__ds_partitioned__quarter + , subq_3.bridge_account__ds_partitioned__year + , subq_3.bridge_account__ds_partitioned__extract_year + , subq_3.bridge_account__ds_partitioned__extract_quarter + , subq_3.bridge_account__ds_partitioned__extract_month + , subq_3.bridge_account__ds_partitioned__extract_day + , subq_3.bridge_account__ds_partitioned__extract_dow + , subq_3.bridge_account__ds_partitioned__extract_doy + , subq_3.ds_partitioned__day AS metric_time__day + , subq_3.ds_partitioned__week AS metric_time__week + , subq_3.ds_partitioned__month AS metric_time__month + , subq_3.ds_partitioned__quarter AS metric_time__quarter + , subq_3.ds_partitioned__year AS metric_time__year + , subq_3.ds_partitioned__extract_year AS metric_time__extract_year + , subq_3.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_3.ds_partitioned__extract_month AS metric_time__extract_month + , subq_3.ds_partitioned__extract_day AS metric_time__extract_day + , subq_3.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_3.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_3.account_id + , subq_3.customer_id + , subq_3.account_id__customer_id + , subq_3.bridge_account__account_id + , subq_3.bridge_account__customer_id + , subq_3.extra_dim + , subq_3.account_id__extra_dim + , subq_3.bridge_account__extra_dim + , subq_3.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -331,8 +331,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -375,86 +375,86 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.customer_id__ds_partitioned__day - , subq_11.customer_id__ds_partitioned__week - , subq_11.customer_id__ds_partitioned__month - , subq_11.customer_id__ds_partitioned__quarter - , subq_11.customer_id__ds_partitioned__year - , subq_11.customer_id__ds_partitioned__extract_year - , subq_11.customer_id__ds_partitioned__extract_quarter - , subq_11.customer_id__ds_partitioned__extract_month - , subq_11.customer_id__ds_partitioned__extract_day - , subq_11.customer_id__ds_partitioned__extract_dow - , subq_11.customer_id__ds_partitioned__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.customer_id - , subq_11.customer_name - , subq_11.customer_atomic_weight - , subq_11.customer_id__customer_name - , subq_11.customer_id__customer_atomic_weight + 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.customer_id__ds_partitioned__day + , subq_6.customer_id__ds_partitioned__week + , subq_6.customer_id__ds_partitioned__month + , subq_6.customer_id__ds_partitioned__quarter + , subq_6.customer_id__ds_partitioned__year + , subq_6.customer_id__ds_partitioned__extract_year + , subq_6.customer_id__ds_partitioned__extract_quarter + , subq_6.customer_id__ds_partitioned__extract_month + , subq_6.customer_id__ds_partitioned__extract_day + , subq_6.customer_id__ds_partitioned__extract_dow + , subq_6.customer_id__ds_partitioned__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.customer_id + , subq_6.customer_name + , subq_6.customer_atomic_weight + , subq_6.customer_id__customer_name + , subq_6.customer_id__customer_atomic_weight FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - 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.customer_id__ds_partitioned__day - , subq_10.customer_id__ds_partitioned__week - , subq_10.customer_id__ds_partitioned__month - , subq_10.customer_id__ds_partitioned__quarter - , subq_10.customer_id__ds_partitioned__year - , subq_10.customer_id__ds_partitioned__extract_year - , subq_10.customer_id__ds_partitioned__extract_quarter - , subq_10.customer_id__ds_partitioned__extract_month - , subq_10.customer_id__ds_partitioned__extract_day - , subq_10.customer_id__ds_partitioned__extract_dow - , subq_10.customer_id__ds_partitioned__extract_doy - , subq_10.ds_partitioned__day AS metric_time__day - , subq_10.ds_partitioned__week AS metric_time__week - , subq_10.ds_partitioned__month AS metric_time__month - , subq_10.ds_partitioned__quarter AS metric_time__quarter - , subq_10.ds_partitioned__year AS metric_time__year - , subq_10.ds_partitioned__extract_year AS metric_time__extract_year - , subq_10.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_10.ds_partitioned__extract_month AS metric_time__extract_month - , subq_10.ds_partitioned__extract_day AS metric_time__extract_day - , subq_10.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_10.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_10.customer_id - , subq_10.customer_name - , subq_10.customer_atomic_weight - , subq_10.customer_id__customer_name - , subq_10.customer_id__customer_atomic_weight - , subq_10.customers + subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.customer_id__ds_partitioned__day + , subq_5.customer_id__ds_partitioned__week + , subq_5.customer_id__ds_partitioned__month + , subq_5.customer_id__ds_partitioned__quarter + , subq_5.customer_id__ds_partitioned__year + , subq_5.customer_id__ds_partitioned__extract_year + , subq_5.customer_id__ds_partitioned__extract_quarter + , subq_5.customer_id__ds_partitioned__extract_month + , subq_5.customer_id__ds_partitioned__extract_day + , subq_5.customer_id__ds_partitioned__extract_dow + , subq_5.customer_id__ds_partitioned__extract_doy + , subq_5.ds_partitioned__day AS metric_time__day + , subq_5.ds_partitioned__week AS metric_time__week + , subq_5.ds_partitioned__month AS metric_time__month + , subq_5.ds_partitioned__quarter AS metric_time__quarter + , subq_5.ds_partitioned__year AS metric_time__year + , subq_5.ds_partitioned__extract_year AS metric_time__extract_year + , subq_5.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_5.ds_partitioned__extract_month AS metric_time__extract_month + , subq_5.ds_partitioned__extract_day AS metric_time__extract_day + , subq_5.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_5.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_5.customer_id + , subq_5.customer_name + , subq_5.customer_atomic_weight + , subq_5.customer_id__customer_name + , subq_5.customer_id__customer_atomic_weight + , subq_5.customers FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT @@ -487,25 +487,25 @@ FROM ( , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy , customer_table_src_22000.customer_id FROM ***************************.customer_table customer_table_src_22000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_5 + ) subq_6 + ) subq_7 ON ( - subq_9.customer_id = subq_12.customer_id + subq_4.customer_id = subq_7.customer_id ) AND ( - subq_9.ds_partitioned__day = subq_12.ds_partitioned__day + subq_4.ds_partitioned__day = subq_7.ds_partitioned__day ) - ) subq_13 - ) subq_14 + ) subq_8 + ) subq_9 ON ( - subq_7.account_id = subq_14.account_id + subq_2.account_id = subq_9.account_id ) AND ( - subq_7.ds_partitioned__day = subq_14.ds_partitioned__day + subq_2.ds_partitioned__day = subq_9.ds_partitioned__day ) - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 GROUP BY - subq_16.account_id__customer_id__customer_name -) subq_17 + subq_11.account_id__customer_id__customer_name +) subq_12 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql index ba4d2593ef..13473156ca 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_32.customer_id__customer_name AS account_id__customer_id__customer_name + subq_22.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -22,12 +22,12 @@ LEFT OUTER JOIN ( ) AND ( DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) ) -) subq_32 +) subq_22 ON ( - account_month_txns_src_22000.account_id = subq_32.account_id + account_month_txns_src_22000.account_id = subq_22.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_32.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_22.ds_partitioned__day ) GROUP BY - subq_32.customer_id__customer_name + subq_22.customer_id__customer_name diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0.sql index 9f6935ca13..175a96a8ba 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0.sql @@ -1,221 +1,221 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_9.bookings) AS bookings - , MAX(subq_15.listings) AS listings + MAX(subq_5.bookings) AS bookings + , MAX(subq_11.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.bookings + subq_4.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_7.bookings) AS bookings + SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_6.bookings + subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -308,165 +308,165 @@ 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_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_6 - ) subq_7 - ) subq_8 -) subq_9 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_2 + ) subq_3 + ) subq_4 +) subq_5 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.listings + subq_10.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_13.listings) AS listings + SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_12.listings + subq_8.listings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.smallest_listing + 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.created_at__day + , subq_7.created_at__week + , subq_7.created_at__month + , subq_7.created_at__quarter + , subq_7.created_at__year + , subq_7.created_at__extract_year + , subq_7.created_at__extract_quarter + , subq_7.created_at__extract_month + , subq_7.created_at__extract_day + , subq_7.created_at__extract_dow + , subq_7.created_at__extract_doy + , subq_7.listing__ds__day + , subq_7.listing__ds__week + , subq_7.listing__ds__month + , subq_7.listing__ds__quarter + , subq_7.listing__ds__year + , subq_7.listing__ds__extract_year + , subq_7.listing__ds__extract_quarter + , subq_7.listing__ds__extract_month + , subq_7.listing__ds__extract_day + , subq_7.listing__ds__extract_dow + , subq_7.listing__ds__extract_doy + , subq_7.listing__created_at__day + , subq_7.listing__created_at__week + , subq_7.listing__created_at__month + , subq_7.listing__created_at__quarter + , subq_7.listing__created_at__year + , subq_7.listing__created_at__extract_year + , subq_7.listing__created_at__extract_quarter + , subq_7.listing__created_at__extract_month + , subq_7.listing__created_at__extract_day + , subq_7.listing__created_at__extract_dow + , subq_7.listing__created_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.user + , subq_7.listing__user + , subq_7.country_latest + , subq_7.is_lux_latest + , subq_7.capacity_latest + , subq_7.listing__country_latest + , subq_7.listing__is_lux_latest + , subq_7.listing__capacity_latest + , subq_7.listings + , subq_7.largest_listing + , subq_7.smallest_listing 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 @@ -527,10 +527,10 @@ CROSS JOIN ( , 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 - WHERE subq_11.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_12 - ) subq_13 - ) subq_14 -) subq_15 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_8 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 265619080c..18ff29de08 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_25.bookings) AS bookings - , MAX(subq_31.listings) AS listings + MAX(subq_17.bookings) AS bookings + , MAX(subq_23.listings) AS listings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -13,7 +13,7 @@ FROM ( SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_25 +) subq_17 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -25,4 +25,4 @@ CROSS JOIN ( SUM(1) AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_31 +) subq_23 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql index fdbdd6f898..104a64b9d6 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day - , CAST(subq_15.booking_value_with_is_instant_constraint AS DOUBLE PRECISION) / CAST(NULLIF(subq_15.booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_value_ratio + subq_13.metric_time__day + , CAST(subq_13.booking_value_with_is_instant_constraint AS DOUBLE PRECISION) / CAST(NULLIF(subq_13.booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - 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 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) AS metric_time__day + , MAX(subq_7.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_12.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_value AS booking_value_with_is_instant_constraint + subq_6.metric_time__day + , subq_6.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_value) AS booking_value + subq_5.metric_time__day + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_value + subq_4.metric_time__day + , subq_4.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.booking_value + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.booking_value + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_5.metric_time__day + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.booking_value + subq_11.metric_time__day + , subq_11.booking_value FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.booking_value) AS booking_value + subq_10.metric_time__day + , SUM(subq_10.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.booking_value + subq_9.metric_time__day + , subq_9.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- 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_10 - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day - ) subq_13 - ) subq_14 + subq_10.metric_time__day + ) subq_11 + ) subq_12 ON - subq_9.metric_time__day = subq_14.metric_time__day + subq_7.metric_time__day = subq_12.metric_time__day GROUP BY - COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) +) subq_13 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql index 2e6e7f62fa..123b56489d 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_25.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_30.booking_value) AS booking_value + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) AS metric_time__day + , MAX(subq_21.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_26.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_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_25 + ) subq_21 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_30 + ) subq_26 ON - subq_25.metric_time__day = subq_30.metric_time__day + subq_21.metric_time__day = subq_26.metric_time__day GROUP BY - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) +) subq_27 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0.sql index 917ad2f2e1..56de086ca3 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,236 +1,236 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day + subq_7.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings AS delayed_bookings + subq_6.metric_time__day + , subq_6.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_5.metric_time__day + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_4.metric_time__day + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE NOT booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE NOT booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_5.metric_time__day + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index 4076d55e53..e23b3a548f 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/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_13 + ) subq_9 WHERE NOT booking__is_instant - ) subq_15 + ) subq_11 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_19 +) subq_15 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql index 803bde072e..2db2db0066 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_21.metric_time__day - , subq_21.listing__user__home_state_latest - , subq_21.bookings + subq_10.metric_time__day + , subq_10.listing__user__home_state_latest + , subq_10.bookings FROM ( -- Aggregate Measures SELECT - subq_20.metric_time__day - , subq_20.listing__user__home_state_latest - , SUM(subq_20.bookings) AS bookings + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest + , SUM(subq_9.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__home_state_latest', 'metric_time__day'] SELECT - subq_19.metric_time__day - , subq_19.listing__user__home_state_latest - , subq_19.bookings + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest + , subq_8.bookings FROM ( -- Join Standard Outputs SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.window_start__day AS listing__window_start__day - , subq_18.window_end__day AS listing__window_end__day - , subq_13.listing AS listing - , subq_18.user__home_state_latest AS listing__user__home_state_latest - , subq_13.bookings AS bookings + subq_2.metric_time__day AS metric_time__day + , subq_7.window_start__day AS listing__window_start__day + , subq_7.window_end__day AS listing__window_end__day + , subq_2.listing AS listing + , subq_7.user__home_state_latest AS listing__user__home_state_latest + , subq_2.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_12.metric_time__day - , subq_12.listing - , subq_12.bookings + subq_1.metric_time__day + , subq_1.listing + , subq_1.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.paid_at__day - , subq_11.paid_at__week - , subq_11.paid_at__month - , subq_11.paid_at__quarter - , subq_11.paid_at__year - , subq_11.paid_at__extract_year - , subq_11.paid_at__extract_quarter - , subq_11.paid_at__extract_month - , subq_11.paid_at__extract_day - , subq_11.paid_at__extract_dow - , subq_11.paid_at__extract_doy - , subq_11.booking__ds__day - , subq_11.booking__ds__week - , subq_11.booking__ds__month - , subq_11.booking__ds__quarter - , subq_11.booking__ds__year - , subq_11.booking__ds__extract_year - , subq_11.booking__ds__extract_quarter - , subq_11.booking__ds__extract_month - , subq_11.booking__ds__extract_day - , subq_11.booking__ds__extract_dow - , subq_11.booking__ds__extract_doy - , subq_11.booking__ds_partitioned__day - , subq_11.booking__ds_partitioned__week - , subq_11.booking__ds_partitioned__month - , subq_11.booking__ds_partitioned__quarter - , subq_11.booking__ds_partitioned__year - , subq_11.booking__ds_partitioned__extract_year - , subq_11.booking__ds_partitioned__extract_quarter - , subq_11.booking__ds_partitioned__extract_month - , subq_11.booking__ds_partitioned__extract_day - , subq_11.booking__ds_partitioned__extract_dow - , subq_11.booking__ds_partitioned__extract_doy - , subq_11.booking__paid_at__day - , subq_11.booking__paid_at__week - , subq_11.booking__paid_at__month - , subq_11.booking__paid_at__quarter - , subq_11.booking__paid_at__year - , subq_11.booking__paid_at__extract_year - , subq_11.booking__paid_at__extract_quarter - , subq_11.booking__paid_at__extract_month - , subq_11.booking__paid_at__extract_day - , subq_11.booking__paid_at__extract_dow - , subq_11.booking__paid_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.guest - , subq_11.host - , subq_11.user - , subq_11.booking__listing - , subq_11.booking__guest - , subq_11.booking__host - , subq_11.booking__user - , subq_11.is_instant - , subq_11.booking__is_instant - , subq_11.bookings - , subq_11.instant_bookings - , subq_11.booking_value - , subq_11.bookers - , subq_11.average_booking_value + 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.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,84 +211,84 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_17.window_start__day - , subq_17.window_end__day - , subq_17.listing - , subq_17.user__home_state_latest + subq_6.window_start__day + , subq_6.window_end__day + , subq_6.listing + , subq_6.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_14.window_start__day AS window_start__day - , subq_14.window_start__week AS window_start__week - , subq_14.window_start__month AS window_start__month - , subq_14.window_start__quarter AS window_start__quarter - , subq_14.window_start__year AS window_start__year - , subq_14.window_start__extract_year AS window_start__extract_year - , subq_14.window_start__extract_quarter AS window_start__extract_quarter - , subq_14.window_start__extract_month AS window_start__extract_month - , subq_14.window_start__extract_day AS window_start__extract_day - , subq_14.window_start__extract_dow AS window_start__extract_dow - , subq_14.window_start__extract_doy AS window_start__extract_doy - , subq_14.window_end__day AS window_end__day - , subq_14.window_end__week AS window_end__week - , subq_14.window_end__month AS window_end__month - , subq_14.window_end__quarter AS window_end__quarter - , subq_14.window_end__year AS window_end__year - , subq_14.window_end__extract_year AS window_end__extract_year - , subq_14.window_end__extract_quarter AS window_end__extract_quarter - , subq_14.window_end__extract_month AS window_end__extract_month - , subq_14.window_end__extract_day AS window_end__extract_day - , subq_14.window_end__extract_dow AS window_end__extract_dow - , subq_14.window_end__extract_doy AS window_end__extract_doy - , subq_14.listing__window_start__day AS listing__window_start__day - , subq_14.listing__window_start__week AS listing__window_start__week - , subq_14.listing__window_start__month AS listing__window_start__month - , subq_14.listing__window_start__quarter AS listing__window_start__quarter - , subq_14.listing__window_start__year AS listing__window_start__year - , subq_14.listing__window_start__extract_year AS listing__window_start__extract_year - , subq_14.listing__window_start__extract_quarter AS listing__window_start__extract_quarter - , subq_14.listing__window_start__extract_month AS listing__window_start__extract_month - , subq_14.listing__window_start__extract_day AS listing__window_start__extract_day - , subq_14.listing__window_start__extract_dow AS listing__window_start__extract_dow - , subq_14.listing__window_start__extract_doy AS listing__window_start__extract_doy - , subq_14.listing__window_end__day AS listing__window_end__day - , subq_14.listing__window_end__week AS listing__window_end__week - , subq_14.listing__window_end__month AS listing__window_end__month - , subq_14.listing__window_end__quarter AS listing__window_end__quarter - , subq_14.listing__window_end__year AS listing__window_end__year - , subq_14.listing__window_end__extract_year AS listing__window_end__extract_year - , subq_14.listing__window_end__extract_quarter AS listing__window_end__extract_quarter - , subq_14.listing__window_end__extract_month AS listing__window_end__extract_month - , subq_14.listing__window_end__extract_day AS listing__window_end__extract_day - , subq_14.listing__window_end__extract_dow AS listing__window_end__extract_dow - , subq_14.listing__window_end__extract_doy AS listing__window_end__extract_doy - , subq_16.ds__day AS user__ds__day - , subq_16.ds__week AS user__ds__week - , subq_16.ds__month AS user__ds__month - , subq_16.ds__quarter AS user__ds__quarter - , subq_16.ds__year AS user__ds__year - , subq_16.ds__extract_year AS user__ds__extract_year - , subq_16.ds__extract_quarter AS user__ds__extract_quarter - , subq_16.ds__extract_month AS user__ds__extract_month - , subq_16.ds__extract_day AS user__ds__extract_day - , subq_16.ds__extract_dow AS user__ds__extract_dow - , subq_16.ds__extract_doy AS user__ds__extract_doy - , subq_14.listing AS listing - , subq_14.user AS user - , subq_14.listing__user AS listing__user - , subq_14.country AS country - , subq_14.is_lux AS is_lux - , subq_14.capacity AS capacity - , subq_14.listing__country AS listing__country - , subq_14.listing__is_lux AS listing__is_lux - , subq_14.listing__capacity AS listing__capacity - , subq_16.home_state_latest AS user__home_state_latest + subq_3.window_start__day AS window_start__day + , subq_3.window_start__week AS window_start__week + , subq_3.window_start__month AS window_start__month + , subq_3.window_start__quarter AS window_start__quarter + , subq_3.window_start__year AS window_start__year + , subq_3.window_start__extract_year AS window_start__extract_year + , subq_3.window_start__extract_quarter AS window_start__extract_quarter + , subq_3.window_start__extract_month AS window_start__extract_month + , subq_3.window_start__extract_day AS window_start__extract_day + , subq_3.window_start__extract_dow AS window_start__extract_dow + , subq_3.window_start__extract_doy AS window_start__extract_doy + , subq_3.window_end__day AS window_end__day + , subq_3.window_end__week AS window_end__week + , subq_3.window_end__month AS window_end__month + , subq_3.window_end__quarter AS window_end__quarter + , subq_3.window_end__year AS window_end__year + , subq_3.window_end__extract_year AS window_end__extract_year + , subq_3.window_end__extract_quarter AS window_end__extract_quarter + , subq_3.window_end__extract_month AS window_end__extract_month + , subq_3.window_end__extract_day AS window_end__extract_day + , subq_3.window_end__extract_dow AS window_end__extract_dow + , subq_3.window_end__extract_doy AS window_end__extract_doy + , subq_3.listing__window_start__day AS listing__window_start__day + , subq_3.listing__window_start__week AS listing__window_start__week + , subq_3.listing__window_start__month AS listing__window_start__month + , subq_3.listing__window_start__quarter AS listing__window_start__quarter + , subq_3.listing__window_start__year AS listing__window_start__year + , subq_3.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_3.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_3.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_3.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_3.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_3.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_3.listing__window_end__day AS listing__window_end__day + , subq_3.listing__window_end__week AS listing__window_end__week + , subq_3.listing__window_end__month AS listing__window_end__month + , subq_3.listing__window_end__quarter AS listing__window_end__quarter + , subq_3.listing__window_end__year AS listing__window_end__year + , subq_3.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_3.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_3.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_3.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_3.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_3.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_5.ds__day AS user__ds__day + , subq_5.ds__week AS user__ds__week + , subq_5.ds__month AS user__ds__month + , subq_5.ds__quarter AS user__ds__quarter + , subq_5.ds__year AS user__ds__year + , subq_5.ds__extract_year AS user__ds__extract_year + , subq_5.ds__extract_quarter AS user__ds__extract_quarter + , subq_5.ds__extract_month AS user__ds__extract_month + , subq_5.ds__extract_day AS user__ds__extract_day + , subq_5.ds__extract_dow AS user__ds__extract_dow + , subq_5.ds__extract_doy AS user__ds__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country AS country + , subq_3.is_lux AS is_lux + , subq_3.capacity AS capacity + , subq_3.listing__country AS listing__country + , subq_3.listing__is_lux AS listing__is_lux + , subq_3.listing__capacity AS listing__capacity + , subq_5.home_state_latest AS user__home_state_latest FROM ( -- Read Elements From Semantic Model 'listings' SELECT @@ -346,7 +346,7 @@ FROM ( , listings_src_26000.user_id AS user , listings_src_26000.user_id AS listing__user FROM ***************************.dim_listings listings_src_26000 - ) subq_14 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,31 +376,31 @@ FROM ( -- 'user', -- ] SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.user__ds__day - , subq_15.user__ds__week - , subq_15.user__ds__month - , subq_15.user__ds__quarter - , subq_15.user__ds__year - , subq_15.user__ds__extract_year - , subq_15.user__ds__extract_quarter - , subq_15.user__ds__extract_month - , subq_15.user__ds__extract_day - , subq_15.user__ds__extract_dow - , subq_15.user__ds__extract_doy - , subq_15.user - , subq_15.home_state_latest - , subq_15.user__home_state_latest + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.user__ds__day + , subq_4.user__ds__week + , subq_4.user__ds__month + , subq_4.user__ds__quarter + , subq_4.user__ds__year + , subq_4.user__ds__extract_year + , subq_4.user__ds__extract_quarter + , subq_4.user__ds__extract_month + , subq_4.user__ds__extract_day + , subq_4.user__ds__extract_dow + , subq_4.user__ds__extract_doy + , subq_4.user + , subq_4.home_state_latest + , subq_4.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -430,29 +430,29 @@ FROM ( , users_latest_src_26000.home_state_latest AS user__home_state_latest , users_latest_src_26000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_26000 - ) subq_15 - ) subq_16 + ) subq_4 + ) subq_5 ON - subq_14.user = subq_16.user - ) subq_17 - ) subq_18 + subq_3.user = subq_5.user + ) subq_6 + ) subq_7 ON ( - subq_13.listing = subq_18.listing + subq_2.listing = subq_7.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_2.metric_time__day >= subq_7.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_2.metric_time__day < subq_7.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_7.window_end__day IS NULL ) ) ) - ) subq_19 - ) subq_20 + ) subq_8 + ) subq_9 GROUP BY - subq_20.metric_time__day - , subq_20.listing__user__home_state_latest -) subq_21 + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest +) subq_10 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql index ad6481bf38..43c459ada2 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_35.metric_time__day AS metric_time__day - , subq_40.user__home_state_latest AS listing__user__home_state_latest - , SUM(subq_35.bookings) AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_18.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,7 +15,7 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_35 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] @@ -29,21 +29,21 @@ LEFT OUTER JOIN ( ***************************.dim_users_latest users_latest_src_26000 ON listings_src_26000.user_id = users_latest_src_26000.user_id -) subq_40 +) subq_18 ON ( - subq_35.listing = subq_40.listing + subq_13.listing = subq_18.listing ) AND ( ( - subq_35.metric_time__day >= subq_40.window_start__day + subq_13.metric_time__day >= subq_18.window_start__day ) AND ( ( - subq_35.metric_time__day < subq_40.window_end__day + subq_13.metric_time__day < subq_18.window_end__day ) OR ( - subq_40.window_end__day IS NULL + subq_18.window_end__day IS NULL ) ) ) GROUP BY - subq_35.metric_time__day - , subq_40.user__home_state_latest + subq_13.metric_time__day + , subq_18.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql index 1fab22334e..b2dfef8dbc 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__lux_listing__is_confirmed_lux - , subq_13.bookings + subq_10.metric_time__day + , subq_10.listing__lux_listing__is_confirmed_lux + , subq_10.bookings FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.listing__lux_listing__is_confirmed_lux - , SUM(subq_12.bookings) AS bookings + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux + , SUM(subq_9.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__lux_listing__is_confirmed_lux', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listing__lux_listing__is_confirmed_lux - , subq_11.bookings + subq_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux + , subq_8.bookings FROM ( -- Join Standard Outputs SELECT - subq_5.metric_time__day AS metric_time__day - , subq_10.lux_listing__window_start__day AS listing__lux_listing__window_start__day - , subq_10.lux_listing__window_end__day AS listing__lux_listing__window_end__day - , subq_5.listing AS listing - , subq_10.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , subq_5.bookings AS bookings + subq_2.metric_time__day AS metric_time__day + , subq_7.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_7.lux_listing__window_end__day AS listing__lux_listing__window_end__day + , subq_2.listing AS listing + , subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_2.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_4.metric_time__day - , subq_4.listing - , subq_4.bookings + subq_1.metric_time__day + , subq_1.listing + , subq_1.bookings 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_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.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.listing - , subq_3.guest - , subq_3.host - , subq_3.user - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.booking__user - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.bookers - , subq_3.average_booking_value + 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.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,45 +211,45 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - subq_9.lux_listing__window_start__day - , subq_9.lux_listing__window_end__day - , subq_9.listing - , subq_9.lux_listing__is_confirmed_lux + subq_6.lux_listing__window_start__day + , subq_6.lux_listing__window_end__day + , subq_6.listing + , subq_6.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_8.window_start__day AS lux_listing__window_start__day - , subq_8.window_start__week AS lux_listing__window_start__week - , subq_8.window_start__month AS lux_listing__window_start__month - , subq_8.window_start__quarter AS lux_listing__window_start__quarter - , subq_8.window_start__year AS lux_listing__window_start__year - , subq_8.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_8.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_8.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_8.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_8.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_8.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_8.window_end__day AS lux_listing__window_end__day - , subq_8.window_end__week AS lux_listing__window_end__week - , subq_8.window_end__month AS lux_listing__window_end__month - , subq_8.window_end__quarter AS lux_listing__window_end__quarter - , subq_8.window_end__year AS lux_listing__window_end__year - , subq_8.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_8.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_8.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_8.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_8.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_8.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_6.listing AS listing - , subq_6.lux_listing AS lux_listing - , subq_6.listing__lux_listing AS listing__lux_listing - , subq_8.is_confirmed_lux AS lux_listing__is_confirmed_lux + subq_5.window_start__day AS lux_listing__window_start__day + , subq_5.window_start__week AS lux_listing__window_start__week + , subq_5.window_start__month AS lux_listing__window_start__month + , subq_5.window_start__quarter AS lux_listing__window_start__quarter + , subq_5.window_start__year AS lux_listing__window_start__year + , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_5.window_end__day AS lux_listing__window_end__day + , subq_5.window_end__week AS lux_listing__window_end__week + , subq_5.window_end__month AS lux_listing__window_end__month + , subq_5.window_end__quarter AS lux_listing__window_end__quarter + , subq_5.window_end__year AS lux_listing__window_end__year + , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_3.listing AS listing + , subq_3.lux_listing AS lux_listing + , subq_3.listing__lux_listing AS listing__lux_listing + , subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -257,7 +257,7 @@ FROM ( , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 - ) subq_6 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,53 +309,53 @@ FROM ( -- 'lux_listing', -- ] SELECT - subq_7.window_start__day - , subq_7.window_start__week - , subq_7.window_start__month - , subq_7.window_start__quarter - , subq_7.window_start__year - , subq_7.window_start__extract_year - , subq_7.window_start__extract_quarter - , subq_7.window_start__extract_month - , subq_7.window_start__extract_day - , subq_7.window_start__extract_dow - , subq_7.window_start__extract_doy - , subq_7.window_end__day - , subq_7.window_end__week - , subq_7.window_end__month - , subq_7.window_end__quarter - , subq_7.window_end__year - , subq_7.window_end__extract_year - , subq_7.window_end__extract_quarter - , subq_7.window_end__extract_month - , subq_7.window_end__extract_day - , subq_7.window_end__extract_dow - , subq_7.window_end__extract_doy - , subq_7.lux_listing__window_start__day - , subq_7.lux_listing__window_start__week - , subq_7.lux_listing__window_start__month - , subq_7.lux_listing__window_start__quarter - , subq_7.lux_listing__window_start__year - , subq_7.lux_listing__window_start__extract_year - , subq_7.lux_listing__window_start__extract_quarter - , subq_7.lux_listing__window_start__extract_month - , subq_7.lux_listing__window_start__extract_day - , subq_7.lux_listing__window_start__extract_dow - , subq_7.lux_listing__window_start__extract_doy - , subq_7.lux_listing__window_end__day - , subq_7.lux_listing__window_end__week - , subq_7.lux_listing__window_end__month - , subq_7.lux_listing__window_end__quarter - , subq_7.lux_listing__window_end__year - , subq_7.lux_listing__window_end__extract_year - , subq_7.lux_listing__window_end__extract_quarter - , subq_7.lux_listing__window_end__extract_month - , subq_7.lux_listing__window_end__extract_day - , subq_7.lux_listing__window_end__extract_dow - , subq_7.lux_listing__window_end__extract_doy - , subq_7.lux_listing - , subq_7.is_confirmed_lux - , subq_7.lux_listing__is_confirmed_lux + subq_4.window_start__day + , subq_4.window_start__week + , subq_4.window_start__month + , subq_4.window_start__quarter + , subq_4.window_start__year + , subq_4.window_start__extract_year + , subq_4.window_start__extract_quarter + , subq_4.window_start__extract_month + , subq_4.window_start__extract_day + , subq_4.window_start__extract_dow + , subq_4.window_start__extract_doy + , subq_4.window_end__day + , subq_4.window_end__week + , subq_4.window_end__month + , subq_4.window_end__quarter + , subq_4.window_end__year + , subq_4.window_end__extract_year + , subq_4.window_end__extract_quarter + , subq_4.window_end__extract_month + , subq_4.window_end__extract_day + , subq_4.window_end__extract_dow + , subq_4.window_end__extract_doy + , subq_4.lux_listing__window_start__day + , subq_4.lux_listing__window_start__week + , subq_4.lux_listing__window_start__month + , subq_4.lux_listing__window_start__quarter + , subq_4.lux_listing__window_start__year + , subq_4.lux_listing__window_start__extract_year + , subq_4.lux_listing__window_start__extract_quarter + , subq_4.lux_listing__window_start__extract_month + , subq_4.lux_listing__window_start__extract_day + , subq_4.lux_listing__window_start__extract_dow + , subq_4.lux_listing__window_start__extract_doy + , subq_4.lux_listing__window_end__day + , subq_4.lux_listing__window_end__week + , subq_4.lux_listing__window_end__month + , subq_4.lux_listing__window_end__quarter + , subq_4.lux_listing__window_end__year + , subq_4.lux_listing__window_end__extract_year + , subq_4.lux_listing__window_end__extract_quarter + , subq_4.lux_listing__window_end__extract_month + , subq_4.lux_listing__window_end__extract_day + , subq_4.lux_listing__window_end__extract_dow + , subq_4.lux_listing__window_end__extract_doy + , subq_4.lux_listing + , subq_4.is_confirmed_lux + , subq_4.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT @@ -407,29 +407,29 @@ FROM ( , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux , lux_listings_src_26000.lux_listing_id AS lux_listing FROM ***************************.dim_lux_listings lux_listings_src_26000 - ) subq_7 - ) subq_8 + ) subq_4 + ) subq_5 ON - subq_6.lux_listing = subq_8.lux_listing - ) subq_9 - ) subq_10 + subq_3.lux_listing = subq_5.lux_listing + ) subq_6 + ) subq_7 ON ( - subq_5.listing = subq_10.listing + subq_2.listing = subq_7.listing ) AND ( ( - subq_5.metric_time__day >= subq_10.lux_listing__window_start__day + subq_2.metric_time__day >= subq_7.lux_listing__window_start__day ) AND ( ( - subq_5.metric_time__day < subq_10.lux_listing__window_end__day + subq_2.metric_time__day < subq_7.lux_listing__window_end__day ) OR ( - subq_10.lux_listing__window_end__day IS NULL + subq_7.lux_listing__window_end__day IS NULL ) ) ) - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 GROUP BY - subq_12.metric_time__day - , subq_12.listing__lux_listing__is_confirmed_lux -) subq_13 + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux +) subq_10 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql index eaaa8aa132..d0d6125e14 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_19.metric_time__day AS metric_time__day - , subq_24.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , SUM(subq_19.bookings) AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_18.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,7 +15,7 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_19 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] @@ -29,21 +29,21 @@ LEFT OUTER JOIN ( ***************************.dim_lux_listings lux_listings_src_26000 ON lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id -) subq_24 +) subq_18 ON ( - subq_19.listing = subq_24.listing + subq_13.listing = subq_18.listing ) AND ( ( - subq_19.metric_time__day >= subq_24.lux_listing__window_start__day + subq_13.metric_time__day >= subq_18.lux_listing__window_start__day ) AND ( ( - subq_19.metric_time__day < subq_24.lux_listing__window_end__day + subq_13.metric_time__day < subq_18.lux_listing__window_end__day ) OR ( - subq_24.lux_listing__window_end__day IS NULL + subq_18.lux_listing__window_end__day IS NULL ) ) ) GROUP BY - subq_19.metric_time__day - , subq_24.lux_listing__is_confirmed_lux + subq_13.metric_time__day + , subq_18.lux_listing__is_confirmed_lux diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql index e4e771cb7c..a2cfac78b0 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql @@ -1,93 +1,93 @@ -- Compute Metrics via Expressions SELECT - subq_17.account_id__customer_id__customer_name - , subq_17.txn_count + subq_12.account_id__customer_id__customer_name + , subq_12.txn_count FROM ( -- Aggregate Measures SELECT - subq_16.account_id__customer_id__customer_name - , SUM(subq_16.txn_count) AS txn_count + subq_11.account_id__customer_id__customer_name + , SUM(subq_11.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_15.account_id__customer_id__customer_name - , subq_15.txn_count + subq_10.account_id__customer_id__customer_name + , subq_10.txn_count FROM ( -- Join Standard Outputs SELECT - subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_14.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_7.account_id AS account_id - , subq_14.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_7.txn_count AS txn_count + subq_2.ds_partitioned__day AS ds_partitioned__day + , subq_9.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_2.account_id AS account_id + , subq_9.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_2.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_6.ds_partitioned__day - , subq_6.account_id - , subq_6.txn_count + subq_1.ds_partitioned__day + , subq_1.account_id + , subq_1.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.account_id__ds_partitioned__day - , subq_5.account_id__ds_partitioned__week - , subq_5.account_id__ds_partitioned__month - , subq_5.account_id__ds_partitioned__quarter - , subq_5.account_id__ds_partitioned__year - , subq_5.account_id__ds_partitioned__extract_year - , subq_5.account_id__ds_partitioned__extract_quarter - , subq_5.account_id__ds_partitioned__extract_month - , subq_5.account_id__ds_partitioned__extract_day - , subq_5.account_id__ds_partitioned__extract_dow - , subq_5.account_id__ds_partitioned__extract_doy - , subq_5.account_id__ds__day - , subq_5.account_id__ds__week - , subq_5.account_id__ds__month - , subq_5.account_id__ds__quarter - , subq_5.account_id__ds__year - , subq_5.account_id__ds__extract_year - , subq_5.account_id__ds__extract_quarter - , subq_5.account_id__ds__extract_month - , subq_5.account_id__ds__extract_day - , subq_5.account_id__ds__extract_dow - , subq_5.account_id__ds__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.account_id - , subq_5.account_month - , subq_5.account_id__account_month - , subq_5.txn_count + 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.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.account_id__ds_partitioned__day + , subq_0.account_id__ds_partitioned__week + , subq_0.account_id__ds_partitioned__month + , subq_0.account_id__ds_partitioned__quarter + , subq_0.account_id__ds_partitioned__year + , subq_0.account_id__ds_partitioned__extract_year + , subq_0.account_id__ds_partitioned__extract_quarter + , subq_0.account_id__ds_partitioned__extract_month + , subq_0.account_id__ds_partitioned__extract_day + , subq_0.account_id__ds_partitioned__extract_dow + , subq_0.account_id__ds_partitioned__extract_doy + , subq_0.account_id__ds__day + , subq_0.account_id__ds__week + , subq_0.account_id__ds__month + , subq_0.account_id__ds__quarter + , subq_0.account_id__ds__year + , subq_0.account_id__ds__extract_year + , subq_0.account_id__ds__extract_quarter + , subq_0.account_id__ds__extract_month + , subq_0.account_id__ds__extract_day + , subq_0.account_id__ds__extract_dow + , subq_0.account_id__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.account_id + , subq_0.account_month + , subq_0.account_id__account_month + , subq_0.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -140,151 +140,151 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_13.ds_partitioned__day - , subq_13.account_id - , subq_13.customer_id__customer_name + subq_8.ds_partitioned__day + , subq_8.account_id + , subq_8.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_9.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_9.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_9.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_9.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_9.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_9.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_9.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_9.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_9.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_9.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_9.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_9.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_9.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_9.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_9.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_9.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_9.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_9.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_9.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_9.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_9.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_9.metric_time__day AS metric_time__day - , subq_9.metric_time__week AS metric_time__week - , subq_9.metric_time__month AS metric_time__month - , subq_9.metric_time__quarter AS metric_time__quarter - , subq_9.metric_time__year AS metric_time__year - , subq_9.metric_time__extract_year AS metric_time__extract_year - , subq_9.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_9.metric_time__extract_month AS metric_time__extract_month - , subq_9.metric_time__extract_day AS metric_time__extract_day - , subq_9.metric_time__extract_dow AS metric_time__extract_dow - , subq_9.metric_time__extract_doy AS metric_time__extract_doy - , subq_12.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_12.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_12.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_12.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_12.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_12.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_12.metric_time__day AS customer_id__metric_time__day - , subq_12.metric_time__week AS customer_id__metric_time__week - , subq_12.metric_time__month AS customer_id__metric_time__month - , subq_12.metric_time__quarter AS customer_id__metric_time__quarter - , subq_12.metric_time__year AS customer_id__metric_time__year - , subq_12.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_12.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_12.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_12.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_12.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_12.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_9.account_id AS account_id - , subq_9.customer_id AS customer_id - , subq_9.account_id__customer_id AS account_id__customer_id - , subq_9.bridge_account__account_id AS bridge_account__account_id - , subq_9.bridge_account__customer_id AS bridge_account__customer_id - , subq_9.extra_dim AS extra_dim - , subq_9.account_id__extra_dim AS account_id__extra_dim - , subq_9.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_12.customer_name AS customer_id__customer_name - , subq_12.customer_atomic_weight AS customer_id__customer_atomic_weight - , subq_9.account_customer_combos AS account_customer_combos + subq_4.ds_partitioned__day AS ds_partitioned__day + , subq_4.ds_partitioned__week AS ds_partitioned__week + , subq_4.ds_partitioned__month AS ds_partitioned__month + , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_4.ds_partitioned__year AS ds_partitioned__year + , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_4.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_4.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_4.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_4.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_4.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_4.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_4.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_4.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_4.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_4.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_4.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_4.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_4.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_4.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_4.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_4.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_4.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_4.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_4.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_4.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_4.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_4.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_4.metric_time__day AS metric_time__day + , subq_4.metric_time__week AS metric_time__week + , subq_4.metric_time__month AS metric_time__month + , subq_4.metric_time__quarter AS metric_time__quarter + , subq_4.metric_time__year AS metric_time__year + , subq_4.metric_time__extract_year AS metric_time__extract_year + , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_4.metric_time__extract_month AS metric_time__extract_month + , subq_4.metric_time__extract_day AS metric_time__extract_day + , subq_4.metric_time__extract_dow AS metric_time__extract_dow + , subq_4.metric_time__extract_doy AS metric_time__extract_doy + , subq_7.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_7.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_7.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_7.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_7.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_7.metric_time__day AS customer_id__metric_time__day + , subq_7.metric_time__week AS customer_id__metric_time__week + , subq_7.metric_time__month AS customer_id__metric_time__month + , subq_7.metric_time__quarter AS customer_id__metric_time__quarter + , subq_7.metric_time__year AS customer_id__metric_time__year + , subq_7.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_7.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_7.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_7.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_7.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_7.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_4.account_id AS account_id + , subq_4.customer_id AS customer_id + , subq_4.account_id__customer_id AS account_id__customer_id + , subq_4.bridge_account__account_id AS bridge_account__account_id + , subq_4.bridge_account__customer_id AS bridge_account__customer_id + , subq_4.extra_dim AS extra_dim + , subq_4.account_id__extra_dim AS account_id__extra_dim + , subq_4.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_7.customer_name AS customer_id__customer_name + , subq_7.customer_atomic_weight AS customer_id__customer_atomic_weight + , subq_4.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.account_id__ds_partitioned__day - , subq_8.account_id__ds_partitioned__week - , subq_8.account_id__ds_partitioned__month - , subq_8.account_id__ds_partitioned__quarter - , subq_8.account_id__ds_partitioned__year - , subq_8.account_id__ds_partitioned__extract_year - , subq_8.account_id__ds_partitioned__extract_quarter - , subq_8.account_id__ds_partitioned__extract_month - , subq_8.account_id__ds_partitioned__extract_day - , subq_8.account_id__ds_partitioned__extract_dow - , subq_8.account_id__ds_partitioned__extract_doy - , subq_8.bridge_account__ds_partitioned__day - , subq_8.bridge_account__ds_partitioned__week - , subq_8.bridge_account__ds_partitioned__month - , subq_8.bridge_account__ds_partitioned__quarter - , subq_8.bridge_account__ds_partitioned__year - , subq_8.bridge_account__ds_partitioned__extract_year - , subq_8.bridge_account__ds_partitioned__extract_quarter - , subq_8.bridge_account__ds_partitioned__extract_month - , subq_8.bridge_account__ds_partitioned__extract_day - , subq_8.bridge_account__ds_partitioned__extract_dow - , subq_8.bridge_account__ds_partitioned__extract_doy - , subq_8.ds_partitioned__day AS metric_time__day - , subq_8.ds_partitioned__week AS metric_time__week - , subq_8.ds_partitioned__month AS metric_time__month - , subq_8.ds_partitioned__quarter AS metric_time__quarter - , subq_8.ds_partitioned__year AS metric_time__year - , subq_8.ds_partitioned__extract_year AS metric_time__extract_year - , subq_8.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_8.ds_partitioned__extract_month AS metric_time__extract_month - , subq_8.ds_partitioned__extract_day AS metric_time__extract_day - , subq_8.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_8.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_8.account_id - , subq_8.customer_id - , subq_8.account_id__customer_id - , subq_8.bridge_account__account_id - , subq_8.bridge_account__customer_id - , subq_8.extra_dim - , subq_8.account_id__extra_dim - , subq_8.bridge_account__extra_dim - , subq_8.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_3.account_id__ds_partitioned__week + , subq_3.account_id__ds_partitioned__month + , subq_3.account_id__ds_partitioned__quarter + , subq_3.account_id__ds_partitioned__year + , subq_3.account_id__ds_partitioned__extract_year + , subq_3.account_id__ds_partitioned__extract_quarter + , subq_3.account_id__ds_partitioned__extract_month + , subq_3.account_id__ds_partitioned__extract_day + , subq_3.account_id__ds_partitioned__extract_dow + , subq_3.account_id__ds_partitioned__extract_doy + , subq_3.bridge_account__ds_partitioned__day + , subq_3.bridge_account__ds_partitioned__week + , subq_3.bridge_account__ds_partitioned__month + , subq_3.bridge_account__ds_partitioned__quarter + , subq_3.bridge_account__ds_partitioned__year + , subq_3.bridge_account__ds_partitioned__extract_year + , subq_3.bridge_account__ds_partitioned__extract_quarter + , subq_3.bridge_account__ds_partitioned__extract_month + , subq_3.bridge_account__ds_partitioned__extract_day + , subq_3.bridge_account__ds_partitioned__extract_dow + , subq_3.bridge_account__ds_partitioned__extract_doy + , subq_3.ds_partitioned__day AS metric_time__day + , subq_3.ds_partitioned__week AS metric_time__week + , subq_3.ds_partitioned__month AS metric_time__month + , subq_3.ds_partitioned__quarter AS metric_time__quarter + , subq_3.ds_partitioned__year AS metric_time__year + , subq_3.ds_partitioned__extract_year AS metric_time__extract_year + , subq_3.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_3.ds_partitioned__extract_month AS metric_time__extract_month + , subq_3.ds_partitioned__extract_day AS metric_time__extract_day + , subq_3.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_3.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_3.account_id + , subq_3.customer_id + , subq_3.account_id__customer_id + , subq_3.bridge_account__account_id + , subq_3.bridge_account__customer_id + , subq_3.extra_dim + , subq_3.account_id__extra_dim + , subq_3.bridge_account__extra_dim + , subq_3.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -331,8 +331,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -375,86 +375,86 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.customer_id__ds_partitioned__day - , subq_11.customer_id__ds_partitioned__week - , subq_11.customer_id__ds_partitioned__month - , subq_11.customer_id__ds_partitioned__quarter - , subq_11.customer_id__ds_partitioned__year - , subq_11.customer_id__ds_partitioned__extract_year - , subq_11.customer_id__ds_partitioned__extract_quarter - , subq_11.customer_id__ds_partitioned__extract_month - , subq_11.customer_id__ds_partitioned__extract_day - , subq_11.customer_id__ds_partitioned__extract_dow - , subq_11.customer_id__ds_partitioned__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.customer_id - , subq_11.customer_name - , subq_11.customer_atomic_weight - , subq_11.customer_id__customer_name - , subq_11.customer_id__customer_atomic_weight + 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.customer_id__ds_partitioned__day + , subq_6.customer_id__ds_partitioned__week + , subq_6.customer_id__ds_partitioned__month + , subq_6.customer_id__ds_partitioned__quarter + , subq_6.customer_id__ds_partitioned__year + , subq_6.customer_id__ds_partitioned__extract_year + , subq_6.customer_id__ds_partitioned__extract_quarter + , subq_6.customer_id__ds_partitioned__extract_month + , subq_6.customer_id__ds_partitioned__extract_day + , subq_6.customer_id__ds_partitioned__extract_dow + , subq_6.customer_id__ds_partitioned__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.customer_id + , subq_6.customer_name + , subq_6.customer_atomic_weight + , subq_6.customer_id__customer_name + , subq_6.customer_id__customer_atomic_weight FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - 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.customer_id__ds_partitioned__day - , subq_10.customer_id__ds_partitioned__week - , subq_10.customer_id__ds_partitioned__month - , subq_10.customer_id__ds_partitioned__quarter - , subq_10.customer_id__ds_partitioned__year - , subq_10.customer_id__ds_partitioned__extract_year - , subq_10.customer_id__ds_partitioned__extract_quarter - , subq_10.customer_id__ds_partitioned__extract_month - , subq_10.customer_id__ds_partitioned__extract_day - , subq_10.customer_id__ds_partitioned__extract_dow - , subq_10.customer_id__ds_partitioned__extract_doy - , subq_10.ds_partitioned__day AS metric_time__day - , subq_10.ds_partitioned__week AS metric_time__week - , subq_10.ds_partitioned__month AS metric_time__month - , subq_10.ds_partitioned__quarter AS metric_time__quarter - , subq_10.ds_partitioned__year AS metric_time__year - , subq_10.ds_partitioned__extract_year AS metric_time__extract_year - , subq_10.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_10.ds_partitioned__extract_month AS metric_time__extract_month - , subq_10.ds_partitioned__extract_day AS metric_time__extract_day - , subq_10.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_10.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_10.customer_id - , subq_10.customer_name - , subq_10.customer_atomic_weight - , subq_10.customer_id__customer_name - , subq_10.customer_id__customer_atomic_weight - , subq_10.customers + subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.customer_id__ds_partitioned__day + , subq_5.customer_id__ds_partitioned__week + , subq_5.customer_id__ds_partitioned__month + , subq_5.customer_id__ds_partitioned__quarter + , subq_5.customer_id__ds_partitioned__year + , subq_5.customer_id__ds_partitioned__extract_year + , subq_5.customer_id__ds_partitioned__extract_quarter + , subq_5.customer_id__ds_partitioned__extract_month + , subq_5.customer_id__ds_partitioned__extract_day + , subq_5.customer_id__ds_partitioned__extract_dow + , subq_5.customer_id__ds_partitioned__extract_doy + , subq_5.ds_partitioned__day AS metric_time__day + , subq_5.ds_partitioned__week AS metric_time__week + , subq_5.ds_partitioned__month AS metric_time__month + , subq_5.ds_partitioned__quarter AS metric_time__quarter + , subq_5.ds_partitioned__year AS metric_time__year + , subq_5.ds_partitioned__extract_year AS metric_time__extract_year + , subq_5.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_5.ds_partitioned__extract_month AS metric_time__extract_month + , subq_5.ds_partitioned__extract_day AS metric_time__extract_day + , subq_5.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_5.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_5.customer_id + , subq_5.customer_name + , subq_5.customer_atomic_weight + , subq_5.customer_id__customer_name + , subq_5.customer_id__customer_atomic_weight + , subq_5.customers FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT @@ -487,25 +487,25 @@ FROM ( , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy , customer_table_src_22000.customer_id FROM ***************************.customer_table customer_table_src_22000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_5 + ) subq_6 + ) subq_7 ON ( - subq_9.customer_id = subq_12.customer_id + subq_4.customer_id = subq_7.customer_id ) AND ( - subq_9.ds_partitioned__day = subq_12.ds_partitioned__day + subq_4.ds_partitioned__day = subq_7.ds_partitioned__day ) - ) subq_13 - ) subq_14 + ) subq_8 + ) subq_9 ON ( - subq_7.account_id = subq_14.account_id + subq_2.account_id = subq_9.account_id ) AND ( - subq_7.ds_partitioned__day = subq_14.ds_partitioned__day + subq_2.ds_partitioned__day = subq_9.ds_partitioned__day ) - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 GROUP BY - subq_16.account_id__customer_id__customer_name -) subq_17 + subq_11.account_id__customer_id__customer_name +) subq_12 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql index ba4d2593ef..13473156ca 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_32.customer_id__customer_name AS account_id__customer_id__customer_name + subq_22.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -22,12 +22,12 @@ LEFT OUTER JOIN ( ) AND ( DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) ) -) subq_32 +) subq_22 ON ( - account_month_txns_src_22000.account_id = subq_32.account_id + account_month_txns_src_22000.account_id = subq_22.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_32.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_22.ds_partitioned__day ) GROUP BY - subq_32.customer_id__customer_name + subq_22.customer_id__customer_name diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0.sql index 29b4886a0a..7eb505d9c1 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0.sql @@ -1,221 +1,221 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_9.bookings) AS bookings - , MAX(subq_15.listings) AS listings + MAX(subq_5.bookings) AS bookings + , MAX(subq_11.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.bookings + subq_4.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_7.bookings) AS bookings + SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_6.bookings + subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -308,165 +308,165 @@ 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_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_6 - ) subq_7 - ) subq_8 -) subq_9 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_2 + ) subq_3 + ) subq_4 +) subq_5 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.listings + subq_10.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_13.listings) AS listings + SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_12.listings + subq_8.listings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.smallest_listing + 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.created_at__day + , subq_7.created_at__week + , subq_7.created_at__month + , subq_7.created_at__quarter + , subq_7.created_at__year + , subq_7.created_at__extract_year + , subq_7.created_at__extract_quarter + , subq_7.created_at__extract_month + , subq_7.created_at__extract_day + , subq_7.created_at__extract_dow + , subq_7.created_at__extract_doy + , subq_7.listing__ds__day + , subq_7.listing__ds__week + , subq_7.listing__ds__month + , subq_7.listing__ds__quarter + , subq_7.listing__ds__year + , subq_7.listing__ds__extract_year + , subq_7.listing__ds__extract_quarter + , subq_7.listing__ds__extract_month + , subq_7.listing__ds__extract_day + , subq_7.listing__ds__extract_dow + , subq_7.listing__ds__extract_doy + , subq_7.listing__created_at__day + , subq_7.listing__created_at__week + , subq_7.listing__created_at__month + , subq_7.listing__created_at__quarter + , subq_7.listing__created_at__year + , subq_7.listing__created_at__extract_year + , subq_7.listing__created_at__extract_quarter + , subq_7.listing__created_at__extract_month + , subq_7.listing__created_at__extract_day + , subq_7.listing__created_at__extract_dow + , subq_7.listing__created_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.user + , subq_7.listing__user + , subq_7.country_latest + , subq_7.is_lux_latest + , subq_7.capacity_latest + , subq_7.listing__country_latest + , subq_7.listing__is_lux_latest + , subq_7.listing__capacity_latest + , subq_7.listings + , subq_7.largest_listing + , subq_7.smallest_listing 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 @@ -527,10 +527,10 @@ CROSS JOIN ( , 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 - WHERE subq_11.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_12 - ) subq_13 - ) subq_14 -) subq_15 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_8 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 265619080c..18ff29de08 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_25.bookings) AS bookings - , MAX(subq_31.listings) AS listings + MAX(subq_17.bookings) AS bookings + , MAX(subq_23.listings) AS listings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -13,7 +13,7 @@ FROM ( SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_25 +) subq_17 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -25,4 +25,4 @@ CROSS JOIN ( SUM(1) AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_31 +) subq_23 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql index 32673ef241..c48066d2fc 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - subq_15.metric_time__day - , CAST(subq_15.booking_value_with_is_instant_constraint AS DOUBLE PRECISION) / CAST(NULLIF(subq_15.booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_value_ratio + subq_13.metric_time__day + , CAST(subq_13.booking_value_with_is_instant_constraint AS DOUBLE PRECISION) / CAST(NULLIF(subq_13.booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - 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 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) AS metric_time__day + , MAX(subq_7.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_12.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_value AS booking_value_with_is_instant_constraint + subq_6.metric_time__day + , subq_6.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_value) AS booking_value + subq_5.metric_time__day + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_value + subq_4.metric_time__day + , subq_4.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.booking_value + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.booking_value + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_5.metric_time__day + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.booking_value + subq_11.metric_time__day + , subq_11.booking_value FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.booking_value) AS booking_value + subq_10.metric_time__day + , SUM(subq_10.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.booking_value + subq_9.metric_time__day + , subq_9.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- 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_10 - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day - ) subq_13 - ) subq_14 + subq_10.metric_time__day + ) subq_11 + ) subq_12 ON - subq_9.metric_time__day = subq_14.metric_time__day + subq_7.metric_time__day = subq_12.metric_time__day GROUP BY - COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) +) subq_13 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql index 2e6e7f62fa..123b56489d 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_25.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_30.booking_value) AS booking_value + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) AS metric_time__day + , MAX(subq_21.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_26.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_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_25 + ) subq_21 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_30 + ) subq_26 ON - subq_25.metric_time__day = subq_30.metric_time__day + subq_21.metric_time__day = subq_26.metric_time__day GROUP BY - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) +) subq_27 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0.sql index e6da332c04..b7377cd75a 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,236 +1,236 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day + subq_7.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings AS delayed_bookings + subq_6.metric_time__day + , subq_6.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_5.metric_time__day + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_4.metric_time__day + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE NOT booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE NOT booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_5.metric_time__day + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index 4076d55e53..e23b3a548f 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/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_13 + ) subq_9 WHERE NOT booking__is_instant - ) subq_15 + ) subq_11 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_19 +) subq_15 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql index 7c1552a14c..fc0e21ba80 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_21.metric_time__day - , subq_21.listing__user__home_state_latest - , subq_21.bookings + subq_10.metric_time__day + , subq_10.listing__user__home_state_latest + , subq_10.bookings FROM ( -- Aggregate Measures SELECT - subq_20.metric_time__day - , subq_20.listing__user__home_state_latest - , SUM(subq_20.bookings) AS bookings + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest + , SUM(subq_9.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__home_state_latest', 'metric_time__day'] SELECT - subq_19.metric_time__day - , subq_19.listing__user__home_state_latest - , subq_19.bookings + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest + , subq_8.bookings FROM ( -- Join Standard Outputs SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.window_start__day AS listing__window_start__day - , subq_18.window_end__day AS listing__window_end__day - , subq_13.listing AS listing - , subq_18.user__home_state_latest AS listing__user__home_state_latest - , subq_13.bookings AS bookings + subq_2.metric_time__day AS metric_time__day + , subq_7.window_start__day AS listing__window_start__day + , subq_7.window_end__day AS listing__window_end__day + , subq_2.listing AS listing + , subq_7.user__home_state_latest AS listing__user__home_state_latest + , subq_2.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_12.metric_time__day - , subq_12.listing - , subq_12.bookings + subq_1.metric_time__day + , subq_1.listing + , subq_1.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.paid_at__day - , subq_11.paid_at__week - , subq_11.paid_at__month - , subq_11.paid_at__quarter - , subq_11.paid_at__year - , subq_11.paid_at__extract_year - , subq_11.paid_at__extract_quarter - , subq_11.paid_at__extract_month - , subq_11.paid_at__extract_day - , subq_11.paid_at__extract_dow - , subq_11.paid_at__extract_doy - , subq_11.booking__ds__day - , subq_11.booking__ds__week - , subq_11.booking__ds__month - , subq_11.booking__ds__quarter - , subq_11.booking__ds__year - , subq_11.booking__ds__extract_year - , subq_11.booking__ds__extract_quarter - , subq_11.booking__ds__extract_month - , subq_11.booking__ds__extract_day - , subq_11.booking__ds__extract_dow - , subq_11.booking__ds__extract_doy - , subq_11.booking__ds_partitioned__day - , subq_11.booking__ds_partitioned__week - , subq_11.booking__ds_partitioned__month - , subq_11.booking__ds_partitioned__quarter - , subq_11.booking__ds_partitioned__year - , subq_11.booking__ds_partitioned__extract_year - , subq_11.booking__ds_partitioned__extract_quarter - , subq_11.booking__ds_partitioned__extract_month - , subq_11.booking__ds_partitioned__extract_day - , subq_11.booking__ds_partitioned__extract_dow - , subq_11.booking__ds_partitioned__extract_doy - , subq_11.booking__paid_at__day - , subq_11.booking__paid_at__week - , subq_11.booking__paid_at__month - , subq_11.booking__paid_at__quarter - , subq_11.booking__paid_at__year - , subq_11.booking__paid_at__extract_year - , subq_11.booking__paid_at__extract_quarter - , subq_11.booking__paid_at__extract_month - , subq_11.booking__paid_at__extract_day - , subq_11.booking__paid_at__extract_dow - , subq_11.booking__paid_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.guest - , subq_11.host - , subq_11.user - , subq_11.booking__listing - , subq_11.booking__guest - , subq_11.booking__host - , subq_11.booking__user - , subq_11.is_instant - , subq_11.booking__is_instant - , subq_11.bookings - , subq_11.instant_bookings - , subq_11.booking_value - , subq_11.bookers - , subq_11.average_booking_value + 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.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,84 +211,84 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_17.window_start__day - , subq_17.window_end__day - , subq_17.listing - , subq_17.user__home_state_latest + subq_6.window_start__day + , subq_6.window_end__day + , subq_6.listing + , subq_6.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_14.window_start__day AS window_start__day - , subq_14.window_start__week AS window_start__week - , subq_14.window_start__month AS window_start__month - , subq_14.window_start__quarter AS window_start__quarter - , subq_14.window_start__year AS window_start__year - , subq_14.window_start__extract_year AS window_start__extract_year - , subq_14.window_start__extract_quarter AS window_start__extract_quarter - , subq_14.window_start__extract_month AS window_start__extract_month - , subq_14.window_start__extract_day AS window_start__extract_day - , subq_14.window_start__extract_dow AS window_start__extract_dow - , subq_14.window_start__extract_doy AS window_start__extract_doy - , subq_14.window_end__day AS window_end__day - , subq_14.window_end__week AS window_end__week - , subq_14.window_end__month AS window_end__month - , subq_14.window_end__quarter AS window_end__quarter - , subq_14.window_end__year AS window_end__year - , subq_14.window_end__extract_year AS window_end__extract_year - , subq_14.window_end__extract_quarter AS window_end__extract_quarter - , subq_14.window_end__extract_month AS window_end__extract_month - , subq_14.window_end__extract_day AS window_end__extract_day - , subq_14.window_end__extract_dow AS window_end__extract_dow - , subq_14.window_end__extract_doy AS window_end__extract_doy - , subq_14.listing__window_start__day AS listing__window_start__day - , subq_14.listing__window_start__week AS listing__window_start__week - , subq_14.listing__window_start__month AS listing__window_start__month - , subq_14.listing__window_start__quarter AS listing__window_start__quarter - , subq_14.listing__window_start__year AS listing__window_start__year - , subq_14.listing__window_start__extract_year AS listing__window_start__extract_year - , subq_14.listing__window_start__extract_quarter AS listing__window_start__extract_quarter - , subq_14.listing__window_start__extract_month AS listing__window_start__extract_month - , subq_14.listing__window_start__extract_day AS listing__window_start__extract_day - , subq_14.listing__window_start__extract_dow AS listing__window_start__extract_dow - , subq_14.listing__window_start__extract_doy AS listing__window_start__extract_doy - , subq_14.listing__window_end__day AS listing__window_end__day - , subq_14.listing__window_end__week AS listing__window_end__week - , subq_14.listing__window_end__month AS listing__window_end__month - , subq_14.listing__window_end__quarter AS listing__window_end__quarter - , subq_14.listing__window_end__year AS listing__window_end__year - , subq_14.listing__window_end__extract_year AS listing__window_end__extract_year - , subq_14.listing__window_end__extract_quarter AS listing__window_end__extract_quarter - , subq_14.listing__window_end__extract_month AS listing__window_end__extract_month - , subq_14.listing__window_end__extract_day AS listing__window_end__extract_day - , subq_14.listing__window_end__extract_dow AS listing__window_end__extract_dow - , subq_14.listing__window_end__extract_doy AS listing__window_end__extract_doy - , subq_16.ds__day AS user__ds__day - , subq_16.ds__week AS user__ds__week - , subq_16.ds__month AS user__ds__month - , subq_16.ds__quarter AS user__ds__quarter - , subq_16.ds__year AS user__ds__year - , subq_16.ds__extract_year AS user__ds__extract_year - , subq_16.ds__extract_quarter AS user__ds__extract_quarter - , subq_16.ds__extract_month AS user__ds__extract_month - , subq_16.ds__extract_day AS user__ds__extract_day - , subq_16.ds__extract_dow AS user__ds__extract_dow - , subq_16.ds__extract_doy AS user__ds__extract_doy - , subq_14.listing AS listing - , subq_14.user AS user - , subq_14.listing__user AS listing__user - , subq_14.country AS country - , subq_14.is_lux AS is_lux - , subq_14.capacity AS capacity - , subq_14.listing__country AS listing__country - , subq_14.listing__is_lux AS listing__is_lux - , subq_14.listing__capacity AS listing__capacity - , subq_16.home_state_latest AS user__home_state_latest + subq_3.window_start__day AS window_start__day + , subq_3.window_start__week AS window_start__week + , subq_3.window_start__month AS window_start__month + , subq_3.window_start__quarter AS window_start__quarter + , subq_3.window_start__year AS window_start__year + , subq_3.window_start__extract_year AS window_start__extract_year + , subq_3.window_start__extract_quarter AS window_start__extract_quarter + , subq_3.window_start__extract_month AS window_start__extract_month + , subq_3.window_start__extract_day AS window_start__extract_day + , subq_3.window_start__extract_dow AS window_start__extract_dow + , subq_3.window_start__extract_doy AS window_start__extract_doy + , subq_3.window_end__day AS window_end__day + , subq_3.window_end__week AS window_end__week + , subq_3.window_end__month AS window_end__month + , subq_3.window_end__quarter AS window_end__quarter + , subq_3.window_end__year AS window_end__year + , subq_3.window_end__extract_year AS window_end__extract_year + , subq_3.window_end__extract_quarter AS window_end__extract_quarter + , subq_3.window_end__extract_month AS window_end__extract_month + , subq_3.window_end__extract_day AS window_end__extract_day + , subq_3.window_end__extract_dow AS window_end__extract_dow + , subq_3.window_end__extract_doy AS window_end__extract_doy + , subq_3.listing__window_start__day AS listing__window_start__day + , subq_3.listing__window_start__week AS listing__window_start__week + , subq_3.listing__window_start__month AS listing__window_start__month + , subq_3.listing__window_start__quarter AS listing__window_start__quarter + , subq_3.listing__window_start__year AS listing__window_start__year + , subq_3.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_3.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_3.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_3.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_3.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_3.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_3.listing__window_end__day AS listing__window_end__day + , subq_3.listing__window_end__week AS listing__window_end__week + , subq_3.listing__window_end__month AS listing__window_end__month + , subq_3.listing__window_end__quarter AS listing__window_end__quarter + , subq_3.listing__window_end__year AS listing__window_end__year + , subq_3.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_3.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_3.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_3.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_3.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_3.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_5.ds__day AS user__ds__day + , subq_5.ds__week AS user__ds__week + , subq_5.ds__month AS user__ds__month + , subq_5.ds__quarter AS user__ds__quarter + , subq_5.ds__year AS user__ds__year + , subq_5.ds__extract_year AS user__ds__extract_year + , subq_5.ds__extract_quarter AS user__ds__extract_quarter + , subq_5.ds__extract_month AS user__ds__extract_month + , subq_5.ds__extract_day AS user__ds__extract_day + , subq_5.ds__extract_dow AS user__ds__extract_dow + , subq_5.ds__extract_doy AS user__ds__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country AS country + , subq_3.is_lux AS is_lux + , subq_3.capacity AS capacity + , subq_3.listing__country AS listing__country + , subq_3.listing__is_lux AS listing__is_lux + , subq_3.listing__capacity AS listing__capacity + , subq_5.home_state_latest AS user__home_state_latest FROM ( -- Read Elements From Semantic Model 'listings' SELECT @@ -346,7 +346,7 @@ FROM ( , listings_src_26000.user_id AS user , listings_src_26000.user_id AS listing__user FROM ***************************.dim_listings listings_src_26000 - ) subq_14 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,31 +376,31 @@ FROM ( -- 'user', -- ] SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.user__ds__day - , subq_15.user__ds__week - , subq_15.user__ds__month - , subq_15.user__ds__quarter - , subq_15.user__ds__year - , subq_15.user__ds__extract_year - , subq_15.user__ds__extract_quarter - , subq_15.user__ds__extract_month - , subq_15.user__ds__extract_day - , subq_15.user__ds__extract_dow - , subq_15.user__ds__extract_doy - , subq_15.user - , subq_15.home_state_latest - , subq_15.user__home_state_latest + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.user__ds__day + , subq_4.user__ds__week + , subq_4.user__ds__month + , subq_4.user__ds__quarter + , subq_4.user__ds__year + , subq_4.user__ds__extract_year + , subq_4.user__ds__extract_quarter + , subq_4.user__ds__extract_month + , subq_4.user__ds__extract_day + , subq_4.user__ds__extract_dow + , subq_4.user__ds__extract_doy + , subq_4.user + , subq_4.home_state_latest + , subq_4.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -430,29 +430,29 @@ FROM ( , users_latest_src_26000.home_state_latest AS user__home_state_latest , users_latest_src_26000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_26000 - ) subq_15 - ) subq_16 + ) subq_4 + ) subq_5 ON - subq_14.user = subq_16.user - ) subq_17 - ) subq_18 + subq_3.user = subq_5.user + ) subq_6 + ) subq_7 ON ( - subq_13.listing = subq_18.listing + subq_2.listing = subq_7.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_2.metric_time__day >= subq_7.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_2.metric_time__day < subq_7.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_7.window_end__day IS NULL ) ) ) - ) subq_19 - ) subq_20 + ) subq_8 + ) subq_9 GROUP BY - subq_20.metric_time__day - , subq_20.listing__user__home_state_latest -) subq_21 + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest +) subq_10 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql index ad6481bf38..43c459ada2 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_35.metric_time__day AS metric_time__day - , subq_40.user__home_state_latest AS listing__user__home_state_latest - , SUM(subq_35.bookings) AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_18.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,7 +15,7 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_35 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] @@ -29,21 +29,21 @@ LEFT OUTER JOIN ( ***************************.dim_users_latest users_latest_src_26000 ON listings_src_26000.user_id = users_latest_src_26000.user_id -) subq_40 +) subq_18 ON ( - subq_35.listing = subq_40.listing + subq_13.listing = subq_18.listing ) AND ( ( - subq_35.metric_time__day >= subq_40.window_start__day + subq_13.metric_time__day >= subq_18.window_start__day ) AND ( ( - subq_35.metric_time__day < subq_40.window_end__day + subq_13.metric_time__day < subq_18.window_end__day ) OR ( - subq_40.window_end__day IS NULL + subq_18.window_end__day IS NULL ) ) ) GROUP BY - subq_35.metric_time__day - , subq_40.user__home_state_latest + subq_13.metric_time__day + , subq_18.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql index fb1756eaea..1b36ee10d2 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__lux_listing__is_confirmed_lux - , subq_13.bookings + subq_10.metric_time__day + , subq_10.listing__lux_listing__is_confirmed_lux + , subq_10.bookings FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.listing__lux_listing__is_confirmed_lux - , SUM(subq_12.bookings) AS bookings + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux + , SUM(subq_9.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__lux_listing__is_confirmed_lux', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listing__lux_listing__is_confirmed_lux - , subq_11.bookings + subq_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux + , subq_8.bookings FROM ( -- Join Standard Outputs SELECT - subq_5.metric_time__day AS metric_time__day - , subq_10.lux_listing__window_start__day AS listing__lux_listing__window_start__day - , subq_10.lux_listing__window_end__day AS listing__lux_listing__window_end__day - , subq_5.listing AS listing - , subq_10.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , subq_5.bookings AS bookings + subq_2.metric_time__day AS metric_time__day + , subq_7.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_7.lux_listing__window_end__day AS listing__lux_listing__window_end__day + , subq_2.listing AS listing + , subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_2.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_4.metric_time__day - , subq_4.listing - , subq_4.bookings + subq_1.metric_time__day + , subq_1.listing + , subq_1.bookings 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_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.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.listing - , subq_3.guest - , subq_3.host - , subq_3.user - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.booking__user - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.bookers - , subq_3.average_booking_value + 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.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,45 +211,45 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - subq_9.lux_listing__window_start__day - , subq_9.lux_listing__window_end__day - , subq_9.listing - , subq_9.lux_listing__is_confirmed_lux + subq_6.lux_listing__window_start__day + , subq_6.lux_listing__window_end__day + , subq_6.listing + , subq_6.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_8.window_start__day AS lux_listing__window_start__day - , subq_8.window_start__week AS lux_listing__window_start__week - , subq_8.window_start__month AS lux_listing__window_start__month - , subq_8.window_start__quarter AS lux_listing__window_start__quarter - , subq_8.window_start__year AS lux_listing__window_start__year - , subq_8.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_8.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_8.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_8.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_8.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_8.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_8.window_end__day AS lux_listing__window_end__day - , subq_8.window_end__week AS lux_listing__window_end__week - , subq_8.window_end__month AS lux_listing__window_end__month - , subq_8.window_end__quarter AS lux_listing__window_end__quarter - , subq_8.window_end__year AS lux_listing__window_end__year - , subq_8.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_8.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_8.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_8.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_8.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_8.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_6.listing AS listing - , subq_6.lux_listing AS lux_listing - , subq_6.listing__lux_listing AS listing__lux_listing - , subq_8.is_confirmed_lux AS lux_listing__is_confirmed_lux + subq_5.window_start__day AS lux_listing__window_start__day + , subq_5.window_start__week AS lux_listing__window_start__week + , subq_5.window_start__month AS lux_listing__window_start__month + , subq_5.window_start__quarter AS lux_listing__window_start__quarter + , subq_5.window_start__year AS lux_listing__window_start__year + , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_5.window_end__day AS lux_listing__window_end__day + , subq_5.window_end__week AS lux_listing__window_end__week + , subq_5.window_end__month AS lux_listing__window_end__month + , subq_5.window_end__quarter AS lux_listing__window_end__quarter + , subq_5.window_end__year AS lux_listing__window_end__year + , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_3.listing AS listing + , subq_3.lux_listing AS lux_listing + , subq_3.listing__lux_listing AS listing__lux_listing + , subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -257,7 +257,7 @@ FROM ( , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 - ) subq_6 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,53 +309,53 @@ FROM ( -- 'lux_listing', -- ] SELECT - subq_7.window_start__day - , subq_7.window_start__week - , subq_7.window_start__month - , subq_7.window_start__quarter - , subq_7.window_start__year - , subq_7.window_start__extract_year - , subq_7.window_start__extract_quarter - , subq_7.window_start__extract_month - , subq_7.window_start__extract_day - , subq_7.window_start__extract_dow - , subq_7.window_start__extract_doy - , subq_7.window_end__day - , subq_7.window_end__week - , subq_7.window_end__month - , subq_7.window_end__quarter - , subq_7.window_end__year - , subq_7.window_end__extract_year - , subq_7.window_end__extract_quarter - , subq_7.window_end__extract_month - , subq_7.window_end__extract_day - , subq_7.window_end__extract_dow - , subq_7.window_end__extract_doy - , subq_7.lux_listing__window_start__day - , subq_7.lux_listing__window_start__week - , subq_7.lux_listing__window_start__month - , subq_7.lux_listing__window_start__quarter - , subq_7.lux_listing__window_start__year - , subq_7.lux_listing__window_start__extract_year - , subq_7.lux_listing__window_start__extract_quarter - , subq_7.lux_listing__window_start__extract_month - , subq_7.lux_listing__window_start__extract_day - , subq_7.lux_listing__window_start__extract_dow - , subq_7.lux_listing__window_start__extract_doy - , subq_7.lux_listing__window_end__day - , subq_7.lux_listing__window_end__week - , subq_7.lux_listing__window_end__month - , subq_7.lux_listing__window_end__quarter - , subq_7.lux_listing__window_end__year - , subq_7.lux_listing__window_end__extract_year - , subq_7.lux_listing__window_end__extract_quarter - , subq_7.lux_listing__window_end__extract_month - , subq_7.lux_listing__window_end__extract_day - , subq_7.lux_listing__window_end__extract_dow - , subq_7.lux_listing__window_end__extract_doy - , subq_7.lux_listing - , subq_7.is_confirmed_lux - , subq_7.lux_listing__is_confirmed_lux + subq_4.window_start__day + , subq_4.window_start__week + , subq_4.window_start__month + , subq_4.window_start__quarter + , subq_4.window_start__year + , subq_4.window_start__extract_year + , subq_4.window_start__extract_quarter + , subq_4.window_start__extract_month + , subq_4.window_start__extract_day + , subq_4.window_start__extract_dow + , subq_4.window_start__extract_doy + , subq_4.window_end__day + , subq_4.window_end__week + , subq_4.window_end__month + , subq_4.window_end__quarter + , subq_4.window_end__year + , subq_4.window_end__extract_year + , subq_4.window_end__extract_quarter + , subq_4.window_end__extract_month + , subq_4.window_end__extract_day + , subq_4.window_end__extract_dow + , subq_4.window_end__extract_doy + , subq_4.lux_listing__window_start__day + , subq_4.lux_listing__window_start__week + , subq_4.lux_listing__window_start__month + , subq_4.lux_listing__window_start__quarter + , subq_4.lux_listing__window_start__year + , subq_4.lux_listing__window_start__extract_year + , subq_4.lux_listing__window_start__extract_quarter + , subq_4.lux_listing__window_start__extract_month + , subq_4.lux_listing__window_start__extract_day + , subq_4.lux_listing__window_start__extract_dow + , subq_4.lux_listing__window_start__extract_doy + , subq_4.lux_listing__window_end__day + , subq_4.lux_listing__window_end__week + , subq_4.lux_listing__window_end__month + , subq_4.lux_listing__window_end__quarter + , subq_4.lux_listing__window_end__year + , subq_4.lux_listing__window_end__extract_year + , subq_4.lux_listing__window_end__extract_quarter + , subq_4.lux_listing__window_end__extract_month + , subq_4.lux_listing__window_end__extract_day + , subq_4.lux_listing__window_end__extract_dow + , subq_4.lux_listing__window_end__extract_doy + , subq_4.lux_listing + , subq_4.is_confirmed_lux + , subq_4.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT @@ -407,29 +407,29 @@ FROM ( , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux , lux_listings_src_26000.lux_listing_id AS lux_listing FROM ***************************.dim_lux_listings lux_listings_src_26000 - ) subq_7 - ) subq_8 + ) subq_4 + ) subq_5 ON - subq_6.lux_listing = subq_8.lux_listing - ) subq_9 - ) subq_10 + subq_3.lux_listing = subq_5.lux_listing + ) subq_6 + ) subq_7 ON ( - subq_5.listing = subq_10.listing + subq_2.listing = subq_7.listing ) AND ( ( - subq_5.metric_time__day >= subq_10.lux_listing__window_start__day + subq_2.metric_time__day >= subq_7.lux_listing__window_start__day ) AND ( ( - subq_5.metric_time__day < subq_10.lux_listing__window_end__day + subq_2.metric_time__day < subq_7.lux_listing__window_end__day ) OR ( - subq_10.lux_listing__window_end__day IS NULL + subq_7.lux_listing__window_end__day IS NULL ) ) ) - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 GROUP BY - subq_12.metric_time__day - , subq_12.listing__lux_listing__is_confirmed_lux -) subq_13 + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux +) subq_10 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql index eaaa8aa132..d0d6125e14 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_19.metric_time__day AS metric_time__day - , subq_24.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , SUM(subq_19.bookings) AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_18.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,7 +15,7 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_19 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] @@ -29,21 +29,21 @@ LEFT OUTER JOIN ( ***************************.dim_lux_listings lux_listings_src_26000 ON lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id -) subq_24 +) subq_18 ON ( - subq_19.listing = subq_24.listing + subq_13.listing = subq_18.listing ) AND ( ( - subq_19.metric_time__day >= subq_24.lux_listing__window_start__day + subq_13.metric_time__day >= subq_18.lux_listing__window_start__day ) AND ( ( - subq_19.metric_time__day < subq_24.lux_listing__window_end__day + subq_13.metric_time__day < subq_18.lux_listing__window_end__day ) OR ( - subq_24.lux_listing__window_end__day IS NULL + subq_18.lux_listing__window_end__day IS NULL ) ) ) GROUP BY - subq_19.metric_time__day - , subq_24.lux_listing__is_confirmed_lux + subq_13.metric_time__day + , subq_18.lux_listing__is_confirmed_lux diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql index d6df2f60b8..7d90a6fa5f 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql @@ -1,93 +1,93 @@ -- Compute Metrics via Expressions SELECT - subq_17.account_id__customer_id__customer_name - , subq_17.txn_count + subq_12.account_id__customer_id__customer_name + , subq_12.txn_count FROM ( -- Aggregate Measures SELECT - subq_16.account_id__customer_id__customer_name - , SUM(subq_16.txn_count) AS txn_count + subq_11.account_id__customer_id__customer_name + , SUM(subq_11.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_15.account_id__customer_id__customer_name - , subq_15.txn_count + subq_10.account_id__customer_id__customer_name + , subq_10.txn_count FROM ( -- Join Standard Outputs SELECT - subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_14.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_7.account_id AS account_id - , subq_14.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_7.txn_count AS txn_count + subq_2.ds_partitioned__day AS ds_partitioned__day + , subq_9.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_2.account_id AS account_id + , subq_9.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_2.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_6.ds_partitioned__day - , subq_6.account_id - , subq_6.txn_count + subq_1.ds_partitioned__day + , subq_1.account_id + , subq_1.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.account_id__ds_partitioned__day - , subq_5.account_id__ds_partitioned__week - , subq_5.account_id__ds_partitioned__month - , subq_5.account_id__ds_partitioned__quarter - , subq_5.account_id__ds_partitioned__year - , subq_5.account_id__ds_partitioned__extract_year - , subq_5.account_id__ds_partitioned__extract_quarter - , subq_5.account_id__ds_partitioned__extract_month - , subq_5.account_id__ds_partitioned__extract_day - , subq_5.account_id__ds_partitioned__extract_dow - , subq_5.account_id__ds_partitioned__extract_doy - , subq_5.account_id__ds__day - , subq_5.account_id__ds__week - , subq_5.account_id__ds__month - , subq_5.account_id__ds__quarter - , subq_5.account_id__ds__year - , subq_5.account_id__ds__extract_year - , subq_5.account_id__ds__extract_quarter - , subq_5.account_id__ds__extract_month - , subq_5.account_id__ds__extract_day - , subq_5.account_id__ds__extract_dow - , subq_5.account_id__ds__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.account_id - , subq_5.account_month - , subq_5.account_id__account_month - , subq_5.txn_count + 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.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.account_id__ds_partitioned__day + , subq_0.account_id__ds_partitioned__week + , subq_0.account_id__ds_partitioned__month + , subq_0.account_id__ds_partitioned__quarter + , subq_0.account_id__ds_partitioned__year + , subq_0.account_id__ds_partitioned__extract_year + , subq_0.account_id__ds_partitioned__extract_quarter + , subq_0.account_id__ds_partitioned__extract_month + , subq_0.account_id__ds_partitioned__extract_day + , subq_0.account_id__ds_partitioned__extract_dow + , subq_0.account_id__ds_partitioned__extract_doy + , subq_0.account_id__ds__day + , subq_0.account_id__ds__week + , subq_0.account_id__ds__month + , subq_0.account_id__ds__quarter + , subq_0.account_id__ds__year + , subq_0.account_id__ds__extract_year + , subq_0.account_id__ds__extract_quarter + , subq_0.account_id__ds__extract_month + , subq_0.account_id__ds__extract_day + , subq_0.account_id__ds__extract_dow + , subq_0.account_id__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.account_id + , subq_0.account_month + , subq_0.account_id__account_month + , subq_0.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -140,151 +140,151 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_13.ds_partitioned__day - , subq_13.account_id - , subq_13.customer_id__customer_name + subq_8.ds_partitioned__day + , subq_8.account_id + , subq_8.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_9.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_9.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_9.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_9.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_9.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_9.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_9.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_9.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_9.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_9.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_9.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_9.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_9.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_9.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_9.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_9.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_9.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_9.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_9.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_9.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_9.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_9.metric_time__day AS metric_time__day - , subq_9.metric_time__week AS metric_time__week - , subq_9.metric_time__month AS metric_time__month - , subq_9.metric_time__quarter AS metric_time__quarter - , subq_9.metric_time__year AS metric_time__year - , subq_9.metric_time__extract_year AS metric_time__extract_year - , subq_9.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_9.metric_time__extract_month AS metric_time__extract_month - , subq_9.metric_time__extract_day AS metric_time__extract_day - , subq_9.metric_time__extract_dow AS metric_time__extract_dow - , subq_9.metric_time__extract_doy AS metric_time__extract_doy - , subq_12.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_12.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_12.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_12.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_12.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_12.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_12.metric_time__day AS customer_id__metric_time__day - , subq_12.metric_time__week AS customer_id__metric_time__week - , subq_12.metric_time__month AS customer_id__metric_time__month - , subq_12.metric_time__quarter AS customer_id__metric_time__quarter - , subq_12.metric_time__year AS customer_id__metric_time__year - , subq_12.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_12.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_12.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_12.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_12.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_12.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_9.account_id AS account_id - , subq_9.customer_id AS customer_id - , subq_9.account_id__customer_id AS account_id__customer_id - , subq_9.bridge_account__account_id AS bridge_account__account_id - , subq_9.bridge_account__customer_id AS bridge_account__customer_id - , subq_9.extra_dim AS extra_dim - , subq_9.account_id__extra_dim AS account_id__extra_dim - , subq_9.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_12.customer_name AS customer_id__customer_name - , subq_12.customer_atomic_weight AS customer_id__customer_atomic_weight - , subq_9.account_customer_combos AS account_customer_combos + subq_4.ds_partitioned__day AS ds_partitioned__day + , subq_4.ds_partitioned__week AS ds_partitioned__week + , subq_4.ds_partitioned__month AS ds_partitioned__month + , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_4.ds_partitioned__year AS ds_partitioned__year + , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_4.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_4.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_4.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_4.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_4.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_4.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_4.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_4.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_4.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_4.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_4.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_4.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_4.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_4.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_4.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_4.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_4.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_4.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_4.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_4.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_4.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_4.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_4.metric_time__day AS metric_time__day + , subq_4.metric_time__week AS metric_time__week + , subq_4.metric_time__month AS metric_time__month + , subq_4.metric_time__quarter AS metric_time__quarter + , subq_4.metric_time__year AS metric_time__year + , subq_4.metric_time__extract_year AS metric_time__extract_year + , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_4.metric_time__extract_month AS metric_time__extract_month + , subq_4.metric_time__extract_day AS metric_time__extract_day + , subq_4.metric_time__extract_dow AS metric_time__extract_dow + , subq_4.metric_time__extract_doy AS metric_time__extract_doy + , subq_7.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_7.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_7.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_7.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_7.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_7.metric_time__day AS customer_id__metric_time__day + , subq_7.metric_time__week AS customer_id__metric_time__week + , subq_7.metric_time__month AS customer_id__metric_time__month + , subq_7.metric_time__quarter AS customer_id__metric_time__quarter + , subq_7.metric_time__year AS customer_id__metric_time__year + , subq_7.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_7.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_7.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_7.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_7.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_7.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_4.account_id AS account_id + , subq_4.customer_id AS customer_id + , subq_4.account_id__customer_id AS account_id__customer_id + , subq_4.bridge_account__account_id AS bridge_account__account_id + , subq_4.bridge_account__customer_id AS bridge_account__customer_id + , subq_4.extra_dim AS extra_dim + , subq_4.account_id__extra_dim AS account_id__extra_dim + , subq_4.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_7.customer_name AS customer_id__customer_name + , subq_7.customer_atomic_weight AS customer_id__customer_atomic_weight + , subq_4.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.account_id__ds_partitioned__day - , subq_8.account_id__ds_partitioned__week - , subq_8.account_id__ds_partitioned__month - , subq_8.account_id__ds_partitioned__quarter - , subq_8.account_id__ds_partitioned__year - , subq_8.account_id__ds_partitioned__extract_year - , subq_8.account_id__ds_partitioned__extract_quarter - , subq_8.account_id__ds_partitioned__extract_month - , subq_8.account_id__ds_partitioned__extract_day - , subq_8.account_id__ds_partitioned__extract_dow - , subq_8.account_id__ds_partitioned__extract_doy - , subq_8.bridge_account__ds_partitioned__day - , subq_8.bridge_account__ds_partitioned__week - , subq_8.bridge_account__ds_partitioned__month - , subq_8.bridge_account__ds_partitioned__quarter - , subq_8.bridge_account__ds_partitioned__year - , subq_8.bridge_account__ds_partitioned__extract_year - , subq_8.bridge_account__ds_partitioned__extract_quarter - , subq_8.bridge_account__ds_partitioned__extract_month - , subq_8.bridge_account__ds_partitioned__extract_day - , subq_8.bridge_account__ds_partitioned__extract_dow - , subq_8.bridge_account__ds_partitioned__extract_doy - , subq_8.ds_partitioned__day AS metric_time__day - , subq_8.ds_partitioned__week AS metric_time__week - , subq_8.ds_partitioned__month AS metric_time__month - , subq_8.ds_partitioned__quarter AS metric_time__quarter - , subq_8.ds_partitioned__year AS metric_time__year - , subq_8.ds_partitioned__extract_year AS metric_time__extract_year - , subq_8.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_8.ds_partitioned__extract_month AS metric_time__extract_month - , subq_8.ds_partitioned__extract_day AS metric_time__extract_day - , subq_8.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_8.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_8.account_id - , subq_8.customer_id - , subq_8.account_id__customer_id - , subq_8.bridge_account__account_id - , subq_8.bridge_account__customer_id - , subq_8.extra_dim - , subq_8.account_id__extra_dim - , subq_8.bridge_account__extra_dim - , subq_8.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_3.account_id__ds_partitioned__week + , subq_3.account_id__ds_partitioned__month + , subq_3.account_id__ds_partitioned__quarter + , subq_3.account_id__ds_partitioned__year + , subq_3.account_id__ds_partitioned__extract_year + , subq_3.account_id__ds_partitioned__extract_quarter + , subq_3.account_id__ds_partitioned__extract_month + , subq_3.account_id__ds_partitioned__extract_day + , subq_3.account_id__ds_partitioned__extract_dow + , subq_3.account_id__ds_partitioned__extract_doy + , subq_3.bridge_account__ds_partitioned__day + , subq_3.bridge_account__ds_partitioned__week + , subq_3.bridge_account__ds_partitioned__month + , subq_3.bridge_account__ds_partitioned__quarter + , subq_3.bridge_account__ds_partitioned__year + , subq_3.bridge_account__ds_partitioned__extract_year + , subq_3.bridge_account__ds_partitioned__extract_quarter + , subq_3.bridge_account__ds_partitioned__extract_month + , subq_3.bridge_account__ds_partitioned__extract_day + , subq_3.bridge_account__ds_partitioned__extract_dow + , subq_3.bridge_account__ds_partitioned__extract_doy + , subq_3.ds_partitioned__day AS metric_time__day + , subq_3.ds_partitioned__week AS metric_time__week + , subq_3.ds_partitioned__month AS metric_time__month + , subq_3.ds_partitioned__quarter AS metric_time__quarter + , subq_3.ds_partitioned__year AS metric_time__year + , subq_3.ds_partitioned__extract_year AS metric_time__extract_year + , subq_3.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_3.ds_partitioned__extract_month AS metric_time__extract_month + , subq_3.ds_partitioned__extract_day AS metric_time__extract_day + , subq_3.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_3.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_3.account_id + , subq_3.customer_id + , subq_3.account_id__customer_id + , subq_3.bridge_account__account_id + , subq_3.bridge_account__customer_id + , subq_3.extra_dim + , subq_3.account_id__extra_dim + , subq_3.bridge_account__extra_dim + , subq_3.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -331,8 +331,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -375,86 +375,86 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.customer_id__ds_partitioned__day - , subq_11.customer_id__ds_partitioned__week - , subq_11.customer_id__ds_partitioned__month - , subq_11.customer_id__ds_partitioned__quarter - , subq_11.customer_id__ds_partitioned__year - , subq_11.customer_id__ds_partitioned__extract_year - , subq_11.customer_id__ds_partitioned__extract_quarter - , subq_11.customer_id__ds_partitioned__extract_month - , subq_11.customer_id__ds_partitioned__extract_day - , subq_11.customer_id__ds_partitioned__extract_dow - , subq_11.customer_id__ds_partitioned__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.customer_id - , subq_11.customer_name - , subq_11.customer_atomic_weight - , subq_11.customer_id__customer_name - , subq_11.customer_id__customer_atomic_weight + 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.customer_id__ds_partitioned__day + , subq_6.customer_id__ds_partitioned__week + , subq_6.customer_id__ds_partitioned__month + , subq_6.customer_id__ds_partitioned__quarter + , subq_6.customer_id__ds_partitioned__year + , subq_6.customer_id__ds_partitioned__extract_year + , subq_6.customer_id__ds_partitioned__extract_quarter + , subq_6.customer_id__ds_partitioned__extract_month + , subq_6.customer_id__ds_partitioned__extract_day + , subq_6.customer_id__ds_partitioned__extract_dow + , subq_6.customer_id__ds_partitioned__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.customer_id + , subq_6.customer_name + , subq_6.customer_atomic_weight + , subq_6.customer_id__customer_name + , subq_6.customer_id__customer_atomic_weight FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - 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.customer_id__ds_partitioned__day - , subq_10.customer_id__ds_partitioned__week - , subq_10.customer_id__ds_partitioned__month - , subq_10.customer_id__ds_partitioned__quarter - , subq_10.customer_id__ds_partitioned__year - , subq_10.customer_id__ds_partitioned__extract_year - , subq_10.customer_id__ds_partitioned__extract_quarter - , subq_10.customer_id__ds_partitioned__extract_month - , subq_10.customer_id__ds_partitioned__extract_day - , subq_10.customer_id__ds_partitioned__extract_dow - , subq_10.customer_id__ds_partitioned__extract_doy - , subq_10.ds_partitioned__day AS metric_time__day - , subq_10.ds_partitioned__week AS metric_time__week - , subq_10.ds_partitioned__month AS metric_time__month - , subq_10.ds_partitioned__quarter AS metric_time__quarter - , subq_10.ds_partitioned__year AS metric_time__year - , subq_10.ds_partitioned__extract_year AS metric_time__extract_year - , subq_10.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_10.ds_partitioned__extract_month AS metric_time__extract_month - , subq_10.ds_partitioned__extract_day AS metric_time__extract_day - , subq_10.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_10.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_10.customer_id - , subq_10.customer_name - , subq_10.customer_atomic_weight - , subq_10.customer_id__customer_name - , subq_10.customer_id__customer_atomic_weight - , subq_10.customers + subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.customer_id__ds_partitioned__day + , subq_5.customer_id__ds_partitioned__week + , subq_5.customer_id__ds_partitioned__month + , subq_5.customer_id__ds_partitioned__quarter + , subq_5.customer_id__ds_partitioned__year + , subq_5.customer_id__ds_partitioned__extract_year + , subq_5.customer_id__ds_partitioned__extract_quarter + , subq_5.customer_id__ds_partitioned__extract_month + , subq_5.customer_id__ds_partitioned__extract_day + , subq_5.customer_id__ds_partitioned__extract_dow + , subq_5.customer_id__ds_partitioned__extract_doy + , subq_5.ds_partitioned__day AS metric_time__day + , subq_5.ds_partitioned__week AS metric_time__week + , subq_5.ds_partitioned__month AS metric_time__month + , subq_5.ds_partitioned__quarter AS metric_time__quarter + , subq_5.ds_partitioned__year AS metric_time__year + , subq_5.ds_partitioned__extract_year AS metric_time__extract_year + , subq_5.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_5.ds_partitioned__extract_month AS metric_time__extract_month + , subq_5.ds_partitioned__extract_day AS metric_time__extract_day + , subq_5.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_5.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_5.customer_id + , subq_5.customer_name + , subq_5.customer_atomic_weight + , subq_5.customer_id__customer_name + , subq_5.customer_id__customer_atomic_weight + , subq_5.customers FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT @@ -487,25 +487,25 @@ FROM ( , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy , customer_table_src_22000.customer_id FROM ***************************.customer_table customer_table_src_22000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_5 + ) subq_6 + ) subq_7 ON ( - subq_9.customer_id = subq_12.customer_id + subq_4.customer_id = subq_7.customer_id ) AND ( - subq_9.ds_partitioned__day = subq_12.ds_partitioned__day + subq_4.ds_partitioned__day = subq_7.ds_partitioned__day ) - ) subq_13 - ) subq_14 + ) subq_8 + ) subq_9 ON ( - subq_7.account_id = subq_14.account_id + subq_2.account_id = subq_9.account_id ) AND ( - subq_7.ds_partitioned__day = subq_14.ds_partitioned__day + subq_2.ds_partitioned__day = subq_9.ds_partitioned__day ) - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 GROUP BY - subq_16.account_id__customer_id__customer_name -) subq_17 + subq_11.account_id__customer_id__customer_name +) subq_12 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql index ba4d2593ef..13473156ca 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_32.customer_id__customer_name AS account_id__customer_id__customer_name + subq_22.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -22,12 +22,12 @@ LEFT OUTER JOIN ( ) AND ( DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) ) -) subq_32 +) subq_22 ON ( - account_month_txns_src_22000.account_id = subq_32.account_id + account_month_txns_src_22000.account_id = subq_22.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_32.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_22.ds_partitioned__day ) GROUP BY - subq_32.customer_id__customer_name + subq_22.customer_id__customer_name diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0.sql index 179a540bd5..ae6fc35582 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0.sql @@ -1,221 +1,221 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_9.bookings) AS bookings - , MAX(subq_15.listings) AS listings + MAX(subq_5.bookings) AS bookings + , MAX(subq_11.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.bookings + subq_4.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_7.bookings) AS bookings + SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_6.bookings + subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -308,165 +308,165 @@ 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_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_6 - ) subq_7 - ) subq_8 -) subq_9 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_2 + ) subq_3 + ) subq_4 +) subq_5 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.listings + subq_10.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_13.listings) AS listings + SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_12.listings + subq_8.listings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.smallest_listing + 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.created_at__day + , subq_7.created_at__week + , subq_7.created_at__month + , subq_7.created_at__quarter + , subq_7.created_at__year + , subq_7.created_at__extract_year + , subq_7.created_at__extract_quarter + , subq_7.created_at__extract_month + , subq_7.created_at__extract_day + , subq_7.created_at__extract_dow + , subq_7.created_at__extract_doy + , subq_7.listing__ds__day + , subq_7.listing__ds__week + , subq_7.listing__ds__month + , subq_7.listing__ds__quarter + , subq_7.listing__ds__year + , subq_7.listing__ds__extract_year + , subq_7.listing__ds__extract_quarter + , subq_7.listing__ds__extract_month + , subq_7.listing__ds__extract_day + , subq_7.listing__ds__extract_dow + , subq_7.listing__ds__extract_doy + , subq_7.listing__created_at__day + , subq_7.listing__created_at__week + , subq_7.listing__created_at__month + , subq_7.listing__created_at__quarter + , subq_7.listing__created_at__year + , subq_7.listing__created_at__extract_year + , subq_7.listing__created_at__extract_quarter + , subq_7.listing__created_at__extract_month + , subq_7.listing__created_at__extract_day + , subq_7.listing__created_at__extract_dow + , subq_7.listing__created_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.user + , subq_7.listing__user + , subq_7.country_latest + , subq_7.is_lux_latest + , subq_7.capacity_latest + , subq_7.listing__country_latest + , subq_7.listing__is_lux_latest + , subq_7.listing__capacity_latest + , subq_7.listings + , subq_7.largest_listing + , subq_7.smallest_listing 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 @@ -527,10 +527,10 @@ CROSS JOIN ( , 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 - WHERE subq_11.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_12 - ) subq_13 - ) subq_14 -) subq_15 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_8 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 265619080c..18ff29de08 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_25.bookings) AS bookings - , MAX(subq_31.listings) AS listings + MAX(subq_17.bookings) AS bookings + , MAX(subq_23.listings) AS listings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -13,7 +13,7 @@ FROM ( SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_25 +) subq_17 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -25,4 +25,4 @@ CROSS JOIN ( SUM(1) AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_31 +) subq_23 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql index b83572690f..ab327fbc8f 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - 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 + subq_13.metric_time__day + , CAST(subq_13.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_13.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - 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 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) AS metric_time__day + , MAX(subq_7.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_12.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_value AS booking_value_with_is_instant_constraint + subq_6.metric_time__day + , subq_6.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_value) AS booking_value + subq_5.metric_time__day + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_value + subq_4.metric_time__day + , subq_4.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.booking_value + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.booking_value + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_5.metric_time__day + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.booking_value + subq_11.metric_time__day + , subq_11.booking_value FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.booking_value) AS booking_value + subq_10.metric_time__day + , SUM(subq_10.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.booking_value + subq_9.metric_time__day + , subq_9.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- 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_10 - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day - ) subq_13 - ) subq_14 + subq_10.metric_time__day + ) subq_11 + ) subq_12 ON - subq_9.metric_time__day = subq_14.metric_time__day + subq_7.metric_time__day = subq_12.metric_time__day GROUP BY - COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) +) subq_13 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql index a795130ca2..bd85051779 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_25.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_30.booking_value) AS booking_value + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) AS metric_time__day + , MAX(subq_21.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_26.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_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_25 + ) subq_21 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_30 + ) subq_26 ON - subq_25.metric_time__day = subq_30.metric_time__day + subq_21.metric_time__day = subq_26.metric_time__day GROUP BY - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) +) subq_27 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0.sql index bb5826ee1e..d5e40eb052 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,236 +1,236 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day + subq_7.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings AS delayed_bookings + subq_6.metric_time__day + , subq_6.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_5.metric_time__day + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_4.metric_time__day + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE NOT booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE NOT booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_5.metric_time__day + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index 4076d55e53..e23b3a548f 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/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_13 + ) subq_9 WHERE NOT booking__is_instant - ) subq_15 + ) subq_11 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_19 +) subq_15 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql index 9c32430d08..057513ae3e 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_21.metric_time__day - , subq_21.listing__user__home_state_latest - , subq_21.bookings + subq_10.metric_time__day + , subq_10.listing__user__home_state_latest + , subq_10.bookings FROM ( -- Aggregate Measures SELECT - subq_20.metric_time__day - , subq_20.listing__user__home_state_latest - , SUM(subq_20.bookings) AS bookings + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest + , SUM(subq_9.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__home_state_latest', 'metric_time__day'] SELECT - subq_19.metric_time__day - , subq_19.listing__user__home_state_latest - , subq_19.bookings + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest + , subq_8.bookings FROM ( -- Join Standard Outputs SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.window_start__day AS listing__window_start__day - , subq_18.window_end__day AS listing__window_end__day - , subq_13.listing AS listing - , subq_18.user__home_state_latest AS listing__user__home_state_latest - , subq_13.bookings AS bookings + subq_2.metric_time__day AS metric_time__day + , subq_7.window_start__day AS listing__window_start__day + , subq_7.window_end__day AS listing__window_end__day + , subq_2.listing AS listing + , subq_7.user__home_state_latest AS listing__user__home_state_latest + , subq_2.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_12.metric_time__day - , subq_12.listing - , subq_12.bookings + subq_1.metric_time__day + , subq_1.listing + , subq_1.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.paid_at__day - , subq_11.paid_at__week - , subq_11.paid_at__month - , subq_11.paid_at__quarter - , subq_11.paid_at__year - , subq_11.paid_at__extract_year - , subq_11.paid_at__extract_quarter - , subq_11.paid_at__extract_month - , subq_11.paid_at__extract_day - , subq_11.paid_at__extract_dow - , subq_11.paid_at__extract_doy - , subq_11.booking__ds__day - , subq_11.booking__ds__week - , subq_11.booking__ds__month - , subq_11.booking__ds__quarter - , subq_11.booking__ds__year - , subq_11.booking__ds__extract_year - , subq_11.booking__ds__extract_quarter - , subq_11.booking__ds__extract_month - , subq_11.booking__ds__extract_day - , subq_11.booking__ds__extract_dow - , subq_11.booking__ds__extract_doy - , subq_11.booking__ds_partitioned__day - , subq_11.booking__ds_partitioned__week - , subq_11.booking__ds_partitioned__month - , subq_11.booking__ds_partitioned__quarter - , subq_11.booking__ds_partitioned__year - , subq_11.booking__ds_partitioned__extract_year - , subq_11.booking__ds_partitioned__extract_quarter - , subq_11.booking__ds_partitioned__extract_month - , subq_11.booking__ds_partitioned__extract_day - , subq_11.booking__ds_partitioned__extract_dow - , subq_11.booking__ds_partitioned__extract_doy - , subq_11.booking__paid_at__day - , subq_11.booking__paid_at__week - , subq_11.booking__paid_at__month - , subq_11.booking__paid_at__quarter - , subq_11.booking__paid_at__year - , subq_11.booking__paid_at__extract_year - , subq_11.booking__paid_at__extract_quarter - , subq_11.booking__paid_at__extract_month - , subq_11.booking__paid_at__extract_day - , subq_11.booking__paid_at__extract_dow - , subq_11.booking__paid_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.guest - , subq_11.host - , subq_11.user - , subq_11.booking__listing - , subq_11.booking__guest - , subq_11.booking__host - , subq_11.booking__user - , subq_11.is_instant - , subq_11.booking__is_instant - , subq_11.bookings - , subq_11.instant_bookings - , subq_11.booking_value - , subq_11.bookers - , subq_11.average_booking_value + 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.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,84 +211,84 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_17.window_start__day - , subq_17.window_end__day - , subq_17.listing - , subq_17.user__home_state_latest + subq_6.window_start__day + , subq_6.window_end__day + , subq_6.listing + , subq_6.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_14.window_start__day AS window_start__day - , subq_14.window_start__week AS window_start__week - , subq_14.window_start__month AS window_start__month - , subq_14.window_start__quarter AS window_start__quarter - , subq_14.window_start__year AS window_start__year - , subq_14.window_start__extract_year AS window_start__extract_year - , subq_14.window_start__extract_quarter AS window_start__extract_quarter - , subq_14.window_start__extract_month AS window_start__extract_month - , subq_14.window_start__extract_day AS window_start__extract_day - , subq_14.window_start__extract_dow AS window_start__extract_dow - , subq_14.window_start__extract_doy AS window_start__extract_doy - , subq_14.window_end__day AS window_end__day - , subq_14.window_end__week AS window_end__week - , subq_14.window_end__month AS window_end__month - , subq_14.window_end__quarter AS window_end__quarter - , subq_14.window_end__year AS window_end__year - , subq_14.window_end__extract_year AS window_end__extract_year - , subq_14.window_end__extract_quarter AS window_end__extract_quarter - , subq_14.window_end__extract_month AS window_end__extract_month - , subq_14.window_end__extract_day AS window_end__extract_day - , subq_14.window_end__extract_dow AS window_end__extract_dow - , subq_14.window_end__extract_doy AS window_end__extract_doy - , subq_14.listing__window_start__day AS listing__window_start__day - , subq_14.listing__window_start__week AS listing__window_start__week - , subq_14.listing__window_start__month AS listing__window_start__month - , subq_14.listing__window_start__quarter AS listing__window_start__quarter - , subq_14.listing__window_start__year AS listing__window_start__year - , subq_14.listing__window_start__extract_year AS listing__window_start__extract_year - , subq_14.listing__window_start__extract_quarter AS listing__window_start__extract_quarter - , subq_14.listing__window_start__extract_month AS listing__window_start__extract_month - , subq_14.listing__window_start__extract_day AS listing__window_start__extract_day - , subq_14.listing__window_start__extract_dow AS listing__window_start__extract_dow - , subq_14.listing__window_start__extract_doy AS listing__window_start__extract_doy - , subq_14.listing__window_end__day AS listing__window_end__day - , subq_14.listing__window_end__week AS listing__window_end__week - , subq_14.listing__window_end__month AS listing__window_end__month - , subq_14.listing__window_end__quarter AS listing__window_end__quarter - , subq_14.listing__window_end__year AS listing__window_end__year - , subq_14.listing__window_end__extract_year AS listing__window_end__extract_year - , subq_14.listing__window_end__extract_quarter AS listing__window_end__extract_quarter - , subq_14.listing__window_end__extract_month AS listing__window_end__extract_month - , subq_14.listing__window_end__extract_day AS listing__window_end__extract_day - , subq_14.listing__window_end__extract_dow AS listing__window_end__extract_dow - , subq_14.listing__window_end__extract_doy AS listing__window_end__extract_doy - , subq_16.ds__day AS user__ds__day - , subq_16.ds__week AS user__ds__week - , subq_16.ds__month AS user__ds__month - , subq_16.ds__quarter AS user__ds__quarter - , subq_16.ds__year AS user__ds__year - , subq_16.ds__extract_year AS user__ds__extract_year - , subq_16.ds__extract_quarter AS user__ds__extract_quarter - , subq_16.ds__extract_month AS user__ds__extract_month - , subq_16.ds__extract_day AS user__ds__extract_day - , subq_16.ds__extract_dow AS user__ds__extract_dow - , subq_16.ds__extract_doy AS user__ds__extract_doy - , subq_14.listing AS listing - , subq_14.user AS user - , subq_14.listing__user AS listing__user - , subq_14.country AS country - , subq_14.is_lux AS is_lux - , subq_14.capacity AS capacity - , subq_14.listing__country AS listing__country - , subq_14.listing__is_lux AS listing__is_lux - , subq_14.listing__capacity AS listing__capacity - , subq_16.home_state_latest AS user__home_state_latest + subq_3.window_start__day AS window_start__day + , subq_3.window_start__week AS window_start__week + , subq_3.window_start__month AS window_start__month + , subq_3.window_start__quarter AS window_start__quarter + , subq_3.window_start__year AS window_start__year + , subq_3.window_start__extract_year AS window_start__extract_year + , subq_3.window_start__extract_quarter AS window_start__extract_quarter + , subq_3.window_start__extract_month AS window_start__extract_month + , subq_3.window_start__extract_day AS window_start__extract_day + , subq_3.window_start__extract_dow AS window_start__extract_dow + , subq_3.window_start__extract_doy AS window_start__extract_doy + , subq_3.window_end__day AS window_end__day + , subq_3.window_end__week AS window_end__week + , subq_3.window_end__month AS window_end__month + , subq_3.window_end__quarter AS window_end__quarter + , subq_3.window_end__year AS window_end__year + , subq_3.window_end__extract_year AS window_end__extract_year + , subq_3.window_end__extract_quarter AS window_end__extract_quarter + , subq_3.window_end__extract_month AS window_end__extract_month + , subq_3.window_end__extract_day AS window_end__extract_day + , subq_3.window_end__extract_dow AS window_end__extract_dow + , subq_3.window_end__extract_doy AS window_end__extract_doy + , subq_3.listing__window_start__day AS listing__window_start__day + , subq_3.listing__window_start__week AS listing__window_start__week + , subq_3.listing__window_start__month AS listing__window_start__month + , subq_3.listing__window_start__quarter AS listing__window_start__quarter + , subq_3.listing__window_start__year AS listing__window_start__year + , subq_3.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_3.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_3.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_3.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_3.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_3.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_3.listing__window_end__day AS listing__window_end__day + , subq_3.listing__window_end__week AS listing__window_end__week + , subq_3.listing__window_end__month AS listing__window_end__month + , subq_3.listing__window_end__quarter AS listing__window_end__quarter + , subq_3.listing__window_end__year AS listing__window_end__year + , subq_3.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_3.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_3.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_3.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_3.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_3.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_5.ds__day AS user__ds__day + , subq_5.ds__week AS user__ds__week + , subq_5.ds__month AS user__ds__month + , subq_5.ds__quarter AS user__ds__quarter + , subq_5.ds__year AS user__ds__year + , subq_5.ds__extract_year AS user__ds__extract_year + , subq_5.ds__extract_quarter AS user__ds__extract_quarter + , subq_5.ds__extract_month AS user__ds__extract_month + , subq_5.ds__extract_day AS user__ds__extract_day + , subq_5.ds__extract_dow AS user__ds__extract_dow + , subq_5.ds__extract_doy AS user__ds__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country AS country + , subq_3.is_lux AS is_lux + , subq_3.capacity AS capacity + , subq_3.listing__country AS listing__country + , subq_3.listing__is_lux AS listing__is_lux + , subq_3.listing__capacity AS listing__capacity + , subq_5.home_state_latest AS user__home_state_latest FROM ( -- Read Elements From Semantic Model 'listings' SELECT @@ -346,7 +346,7 @@ FROM ( , listings_src_26000.user_id AS user , listings_src_26000.user_id AS listing__user FROM ***************************.dim_listings listings_src_26000 - ) subq_14 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,31 +376,31 @@ FROM ( -- 'user', -- ] SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.user__ds__day - , subq_15.user__ds__week - , subq_15.user__ds__month - , subq_15.user__ds__quarter - , subq_15.user__ds__year - , subq_15.user__ds__extract_year - , subq_15.user__ds__extract_quarter - , subq_15.user__ds__extract_month - , subq_15.user__ds__extract_day - , subq_15.user__ds__extract_dow - , subq_15.user__ds__extract_doy - , subq_15.user - , subq_15.home_state_latest - , subq_15.user__home_state_latest + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.user__ds__day + , subq_4.user__ds__week + , subq_4.user__ds__month + , subq_4.user__ds__quarter + , subq_4.user__ds__year + , subq_4.user__ds__extract_year + , subq_4.user__ds__extract_quarter + , subq_4.user__ds__extract_month + , subq_4.user__ds__extract_day + , subq_4.user__ds__extract_dow + , subq_4.user__ds__extract_doy + , subq_4.user + , subq_4.home_state_latest + , subq_4.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -430,29 +430,29 @@ FROM ( , users_latest_src_26000.home_state_latest AS user__home_state_latest , users_latest_src_26000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_26000 - ) subq_15 - ) subq_16 + ) subq_4 + ) subq_5 ON - subq_14.user = subq_16.user - ) subq_17 - ) subq_18 + subq_3.user = subq_5.user + ) subq_6 + ) subq_7 ON ( - subq_13.listing = subq_18.listing + subq_2.listing = subq_7.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_2.metric_time__day >= subq_7.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_2.metric_time__day < subq_7.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_7.window_end__day IS NULL ) ) ) - ) subq_19 - ) subq_20 + ) subq_8 + ) subq_9 GROUP BY - subq_20.metric_time__day - , subq_20.listing__user__home_state_latest -) subq_21 + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest +) subq_10 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql index ad6481bf38..43c459ada2 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_35.metric_time__day AS metric_time__day - , subq_40.user__home_state_latest AS listing__user__home_state_latest - , SUM(subq_35.bookings) AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_18.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,7 +15,7 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_35 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] @@ -29,21 +29,21 @@ LEFT OUTER JOIN ( ***************************.dim_users_latest users_latest_src_26000 ON listings_src_26000.user_id = users_latest_src_26000.user_id -) subq_40 +) subq_18 ON ( - subq_35.listing = subq_40.listing + subq_13.listing = subq_18.listing ) AND ( ( - subq_35.metric_time__day >= subq_40.window_start__day + subq_13.metric_time__day >= subq_18.window_start__day ) AND ( ( - subq_35.metric_time__day < subq_40.window_end__day + subq_13.metric_time__day < subq_18.window_end__day ) OR ( - subq_40.window_end__day IS NULL + subq_18.window_end__day IS NULL ) ) ) GROUP BY - subq_35.metric_time__day - , subq_40.user__home_state_latest + subq_13.metric_time__day + , subq_18.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql index ccf2b3ef38..f1f5859d67 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__lux_listing__is_confirmed_lux - , subq_13.bookings + subq_10.metric_time__day + , subq_10.listing__lux_listing__is_confirmed_lux + , subq_10.bookings FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.listing__lux_listing__is_confirmed_lux - , SUM(subq_12.bookings) AS bookings + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux + , SUM(subq_9.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__lux_listing__is_confirmed_lux', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listing__lux_listing__is_confirmed_lux - , subq_11.bookings + subq_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux + , subq_8.bookings FROM ( -- Join Standard Outputs SELECT - subq_5.metric_time__day AS metric_time__day - , subq_10.lux_listing__window_start__day AS listing__lux_listing__window_start__day - , subq_10.lux_listing__window_end__day AS listing__lux_listing__window_end__day - , subq_5.listing AS listing - , subq_10.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , subq_5.bookings AS bookings + subq_2.metric_time__day AS metric_time__day + , subq_7.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_7.lux_listing__window_end__day AS listing__lux_listing__window_end__day + , subq_2.listing AS listing + , subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_2.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_4.metric_time__day - , subq_4.listing - , subq_4.bookings + subq_1.metric_time__day + , subq_1.listing + , subq_1.bookings 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_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.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.listing - , subq_3.guest - , subq_3.host - , subq_3.user - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.booking__user - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.bookers - , subq_3.average_booking_value + 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.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,45 +211,45 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - subq_9.lux_listing__window_start__day - , subq_9.lux_listing__window_end__day - , subq_9.listing - , subq_9.lux_listing__is_confirmed_lux + subq_6.lux_listing__window_start__day + , subq_6.lux_listing__window_end__day + , subq_6.listing + , subq_6.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_8.window_start__day AS lux_listing__window_start__day - , subq_8.window_start__week AS lux_listing__window_start__week - , subq_8.window_start__month AS lux_listing__window_start__month - , subq_8.window_start__quarter AS lux_listing__window_start__quarter - , subq_8.window_start__year AS lux_listing__window_start__year - , subq_8.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_8.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_8.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_8.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_8.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_8.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_8.window_end__day AS lux_listing__window_end__day - , subq_8.window_end__week AS lux_listing__window_end__week - , subq_8.window_end__month AS lux_listing__window_end__month - , subq_8.window_end__quarter AS lux_listing__window_end__quarter - , subq_8.window_end__year AS lux_listing__window_end__year - , subq_8.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_8.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_8.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_8.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_8.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_8.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_6.listing AS listing - , subq_6.lux_listing AS lux_listing - , subq_6.listing__lux_listing AS listing__lux_listing - , subq_8.is_confirmed_lux AS lux_listing__is_confirmed_lux + subq_5.window_start__day AS lux_listing__window_start__day + , subq_5.window_start__week AS lux_listing__window_start__week + , subq_5.window_start__month AS lux_listing__window_start__month + , subq_5.window_start__quarter AS lux_listing__window_start__quarter + , subq_5.window_start__year AS lux_listing__window_start__year + , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_5.window_end__day AS lux_listing__window_end__day + , subq_5.window_end__week AS lux_listing__window_end__week + , subq_5.window_end__month AS lux_listing__window_end__month + , subq_5.window_end__quarter AS lux_listing__window_end__quarter + , subq_5.window_end__year AS lux_listing__window_end__year + , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_3.listing AS listing + , subq_3.lux_listing AS lux_listing + , subq_3.listing__lux_listing AS listing__lux_listing + , subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -257,7 +257,7 @@ FROM ( , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 - ) subq_6 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,53 +309,53 @@ FROM ( -- 'lux_listing', -- ] SELECT - subq_7.window_start__day - , subq_7.window_start__week - , subq_7.window_start__month - , subq_7.window_start__quarter - , subq_7.window_start__year - , subq_7.window_start__extract_year - , subq_7.window_start__extract_quarter - , subq_7.window_start__extract_month - , subq_7.window_start__extract_day - , subq_7.window_start__extract_dow - , subq_7.window_start__extract_doy - , subq_7.window_end__day - , subq_7.window_end__week - , subq_7.window_end__month - , subq_7.window_end__quarter - , subq_7.window_end__year - , subq_7.window_end__extract_year - , subq_7.window_end__extract_quarter - , subq_7.window_end__extract_month - , subq_7.window_end__extract_day - , subq_7.window_end__extract_dow - , subq_7.window_end__extract_doy - , subq_7.lux_listing__window_start__day - , subq_7.lux_listing__window_start__week - , subq_7.lux_listing__window_start__month - , subq_7.lux_listing__window_start__quarter - , subq_7.lux_listing__window_start__year - , subq_7.lux_listing__window_start__extract_year - , subq_7.lux_listing__window_start__extract_quarter - , subq_7.lux_listing__window_start__extract_month - , subq_7.lux_listing__window_start__extract_day - , subq_7.lux_listing__window_start__extract_dow - , subq_7.lux_listing__window_start__extract_doy - , subq_7.lux_listing__window_end__day - , subq_7.lux_listing__window_end__week - , subq_7.lux_listing__window_end__month - , subq_7.lux_listing__window_end__quarter - , subq_7.lux_listing__window_end__year - , subq_7.lux_listing__window_end__extract_year - , subq_7.lux_listing__window_end__extract_quarter - , subq_7.lux_listing__window_end__extract_month - , subq_7.lux_listing__window_end__extract_day - , subq_7.lux_listing__window_end__extract_dow - , subq_7.lux_listing__window_end__extract_doy - , subq_7.lux_listing - , subq_7.is_confirmed_lux - , subq_7.lux_listing__is_confirmed_lux + subq_4.window_start__day + , subq_4.window_start__week + , subq_4.window_start__month + , subq_4.window_start__quarter + , subq_4.window_start__year + , subq_4.window_start__extract_year + , subq_4.window_start__extract_quarter + , subq_4.window_start__extract_month + , subq_4.window_start__extract_day + , subq_4.window_start__extract_dow + , subq_4.window_start__extract_doy + , subq_4.window_end__day + , subq_4.window_end__week + , subq_4.window_end__month + , subq_4.window_end__quarter + , subq_4.window_end__year + , subq_4.window_end__extract_year + , subq_4.window_end__extract_quarter + , subq_4.window_end__extract_month + , subq_4.window_end__extract_day + , subq_4.window_end__extract_dow + , subq_4.window_end__extract_doy + , subq_4.lux_listing__window_start__day + , subq_4.lux_listing__window_start__week + , subq_4.lux_listing__window_start__month + , subq_4.lux_listing__window_start__quarter + , subq_4.lux_listing__window_start__year + , subq_4.lux_listing__window_start__extract_year + , subq_4.lux_listing__window_start__extract_quarter + , subq_4.lux_listing__window_start__extract_month + , subq_4.lux_listing__window_start__extract_day + , subq_4.lux_listing__window_start__extract_dow + , subq_4.lux_listing__window_start__extract_doy + , subq_4.lux_listing__window_end__day + , subq_4.lux_listing__window_end__week + , subq_4.lux_listing__window_end__month + , subq_4.lux_listing__window_end__quarter + , subq_4.lux_listing__window_end__year + , subq_4.lux_listing__window_end__extract_year + , subq_4.lux_listing__window_end__extract_quarter + , subq_4.lux_listing__window_end__extract_month + , subq_4.lux_listing__window_end__extract_day + , subq_4.lux_listing__window_end__extract_dow + , subq_4.lux_listing__window_end__extract_doy + , subq_4.lux_listing + , subq_4.is_confirmed_lux + , subq_4.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT @@ -407,29 +407,29 @@ FROM ( , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux , lux_listings_src_26000.lux_listing_id AS lux_listing FROM ***************************.dim_lux_listings lux_listings_src_26000 - ) subq_7 - ) subq_8 + ) subq_4 + ) subq_5 ON - subq_6.lux_listing = subq_8.lux_listing - ) subq_9 - ) subq_10 + subq_3.lux_listing = subq_5.lux_listing + ) subq_6 + ) subq_7 ON ( - subq_5.listing = subq_10.listing + subq_2.listing = subq_7.listing ) AND ( ( - subq_5.metric_time__day >= subq_10.lux_listing__window_start__day + subq_2.metric_time__day >= subq_7.lux_listing__window_start__day ) AND ( ( - subq_5.metric_time__day < subq_10.lux_listing__window_end__day + subq_2.metric_time__day < subq_7.lux_listing__window_end__day ) OR ( - subq_10.lux_listing__window_end__day IS NULL + subq_7.lux_listing__window_end__day IS NULL ) ) ) - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 GROUP BY - subq_12.metric_time__day - , subq_12.listing__lux_listing__is_confirmed_lux -) subq_13 + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux +) subq_10 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql index eaaa8aa132..d0d6125e14 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_19.metric_time__day AS metric_time__day - , subq_24.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , SUM(subq_19.bookings) AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_18.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,7 +15,7 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_19 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] @@ -29,21 +29,21 @@ LEFT OUTER JOIN ( ***************************.dim_lux_listings lux_listings_src_26000 ON lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id -) subq_24 +) subq_18 ON ( - subq_19.listing = subq_24.listing + subq_13.listing = subq_18.listing ) AND ( ( - subq_19.metric_time__day >= subq_24.lux_listing__window_start__day + subq_13.metric_time__day >= subq_18.lux_listing__window_start__day ) AND ( ( - subq_19.metric_time__day < subq_24.lux_listing__window_end__day + subq_13.metric_time__day < subq_18.lux_listing__window_end__day ) OR ( - subq_24.lux_listing__window_end__day IS NULL + subq_18.lux_listing__window_end__day IS NULL ) ) ) GROUP BY - subq_19.metric_time__day - , subq_24.lux_listing__is_confirmed_lux + subq_13.metric_time__day + , subq_18.lux_listing__is_confirmed_lux diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql index 03dc99f183..f1ed37dd36 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql @@ -1,93 +1,93 @@ -- Compute Metrics via Expressions SELECT - subq_17.account_id__customer_id__customer_name - , subq_17.txn_count + subq_12.account_id__customer_id__customer_name + , subq_12.txn_count FROM ( -- Aggregate Measures SELECT - subq_16.account_id__customer_id__customer_name - , SUM(subq_16.txn_count) AS txn_count + subq_11.account_id__customer_id__customer_name + , SUM(subq_11.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_15.account_id__customer_id__customer_name - , subq_15.txn_count + subq_10.account_id__customer_id__customer_name + , subq_10.txn_count FROM ( -- Join Standard Outputs SELECT - subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_14.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_7.account_id AS account_id - , subq_14.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_7.txn_count AS txn_count + subq_2.ds_partitioned__day AS ds_partitioned__day + , subq_9.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_2.account_id AS account_id + , subq_9.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_2.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_6.ds_partitioned__day - , subq_6.account_id - , subq_6.txn_count + subq_1.ds_partitioned__day + , subq_1.account_id + , subq_1.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.account_id__ds_partitioned__day - , subq_5.account_id__ds_partitioned__week - , subq_5.account_id__ds_partitioned__month - , subq_5.account_id__ds_partitioned__quarter - , subq_5.account_id__ds_partitioned__year - , subq_5.account_id__ds_partitioned__extract_year - , subq_5.account_id__ds_partitioned__extract_quarter - , subq_5.account_id__ds_partitioned__extract_month - , subq_5.account_id__ds_partitioned__extract_day - , subq_5.account_id__ds_partitioned__extract_dow - , subq_5.account_id__ds_partitioned__extract_doy - , subq_5.account_id__ds__day - , subq_5.account_id__ds__week - , subq_5.account_id__ds__month - , subq_5.account_id__ds__quarter - , subq_5.account_id__ds__year - , subq_5.account_id__ds__extract_year - , subq_5.account_id__ds__extract_quarter - , subq_5.account_id__ds__extract_month - , subq_5.account_id__ds__extract_day - , subq_5.account_id__ds__extract_dow - , subq_5.account_id__ds__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.account_id - , subq_5.account_month - , subq_5.account_id__account_month - , subq_5.txn_count + 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.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.account_id__ds_partitioned__day + , subq_0.account_id__ds_partitioned__week + , subq_0.account_id__ds_partitioned__month + , subq_0.account_id__ds_partitioned__quarter + , subq_0.account_id__ds_partitioned__year + , subq_0.account_id__ds_partitioned__extract_year + , subq_0.account_id__ds_partitioned__extract_quarter + , subq_0.account_id__ds_partitioned__extract_month + , subq_0.account_id__ds_partitioned__extract_day + , subq_0.account_id__ds_partitioned__extract_dow + , subq_0.account_id__ds_partitioned__extract_doy + , subq_0.account_id__ds__day + , subq_0.account_id__ds__week + , subq_0.account_id__ds__month + , subq_0.account_id__ds__quarter + , subq_0.account_id__ds__year + , subq_0.account_id__ds__extract_year + , subq_0.account_id__ds__extract_quarter + , subq_0.account_id__ds__extract_month + , subq_0.account_id__ds__extract_day + , subq_0.account_id__ds__extract_dow + , subq_0.account_id__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.account_id + , subq_0.account_month + , subq_0.account_id__account_month + , subq_0.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -140,151 +140,151 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_13.ds_partitioned__day - , subq_13.account_id - , subq_13.customer_id__customer_name + subq_8.ds_partitioned__day + , subq_8.account_id + , subq_8.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_9.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_9.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_9.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_9.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_9.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_9.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_9.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_9.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_9.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_9.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_9.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_9.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_9.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_9.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_9.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_9.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_9.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_9.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_9.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_9.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_9.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_9.metric_time__day AS metric_time__day - , subq_9.metric_time__week AS metric_time__week - , subq_9.metric_time__month AS metric_time__month - , subq_9.metric_time__quarter AS metric_time__quarter - , subq_9.metric_time__year AS metric_time__year - , subq_9.metric_time__extract_year AS metric_time__extract_year - , subq_9.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_9.metric_time__extract_month AS metric_time__extract_month - , subq_9.metric_time__extract_day AS metric_time__extract_day - , subq_9.metric_time__extract_dow AS metric_time__extract_dow - , subq_9.metric_time__extract_doy AS metric_time__extract_doy - , subq_12.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_12.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_12.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_12.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_12.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_12.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_12.metric_time__day AS customer_id__metric_time__day - , subq_12.metric_time__week AS customer_id__metric_time__week - , subq_12.metric_time__month AS customer_id__metric_time__month - , subq_12.metric_time__quarter AS customer_id__metric_time__quarter - , subq_12.metric_time__year AS customer_id__metric_time__year - , subq_12.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_12.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_12.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_12.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_12.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_12.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_9.account_id AS account_id - , subq_9.customer_id AS customer_id - , subq_9.account_id__customer_id AS account_id__customer_id - , subq_9.bridge_account__account_id AS bridge_account__account_id - , subq_9.bridge_account__customer_id AS bridge_account__customer_id - , subq_9.extra_dim AS extra_dim - , subq_9.account_id__extra_dim AS account_id__extra_dim - , subq_9.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_12.customer_name AS customer_id__customer_name - , subq_12.customer_atomic_weight AS customer_id__customer_atomic_weight - , subq_9.account_customer_combos AS account_customer_combos + subq_4.ds_partitioned__day AS ds_partitioned__day + , subq_4.ds_partitioned__week AS ds_partitioned__week + , subq_4.ds_partitioned__month AS ds_partitioned__month + , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_4.ds_partitioned__year AS ds_partitioned__year + , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_4.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_4.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_4.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_4.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_4.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_4.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_4.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_4.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_4.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_4.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_4.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_4.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_4.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_4.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_4.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_4.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_4.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_4.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_4.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_4.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_4.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_4.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_4.metric_time__day AS metric_time__day + , subq_4.metric_time__week AS metric_time__week + , subq_4.metric_time__month AS metric_time__month + , subq_4.metric_time__quarter AS metric_time__quarter + , subq_4.metric_time__year AS metric_time__year + , subq_4.metric_time__extract_year AS metric_time__extract_year + , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_4.metric_time__extract_month AS metric_time__extract_month + , subq_4.metric_time__extract_day AS metric_time__extract_day + , subq_4.metric_time__extract_dow AS metric_time__extract_dow + , subq_4.metric_time__extract_doy AS metric_time__extract_doy + , subq_7.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_7.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_7.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_7.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_7.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_7.metric_time__day AS customer_id__metric_time__day + , subq_7.metric_time__week AS customer_id__metric_time__week + , subq_7.metric_time__month AS customer_id__metric_time__month + , subq_7.metric_time__quarter AS customer_id__metric_time__quarter + , subq_7.metric_time__year AS customer_id__metric_time__year + , subq_7.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_7.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_7.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_7.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_7.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_7.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_4.account_id AS account_id + , subq_4.customer_id AS customer_id + , subq_4.account_id__customer_id AS account_id__customer_id + , subq_4.bridge_account__account_id AS bridge_account__account_id + , subq_4.bridge_account__customer_id AS bridge_account__customer_id + , subq_4.extra_dim AS extra_dim + , subq_4.account_id__extra_dim AS account_id__extra_dim + , subq_4.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_7.customer_name AS customer_id__customer_name + , subq_7.customer_atomic_weight AS customer_id__customer_atomic_weight + , subq_4.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.account_id__ds_partitioned__day - , subq_8.account_id__ds_partitioned__week - , subq_8.account_id__ds_partitioned__month - , subq_8.account_id__ds_partitioned__quarter - , subq_8.account_id__ds_partitioned__year - , subq_8.account_id__ds_partitioned__extract_year - , subq_8.account_id__ds_partitioned__extract_quarter - , subq_8.account_id__ds_partitioned__extract_month - , subq_8.account_id__ds_partitioned__extract_day - , subq_8.account_id__ds_partitioned__extract_dow - , subq_8.account_id__ds_partitioned__extract_doy - , subq_8.bridge_account__ds_partitioned__day - , subq_8.bridge_account__ds_partitioned__week - , subq_8.bridge_account__ds_partitioned__month - , subq_8.bridge_account__ds_partitioned__quarter - , subq_8.bridge_account__ds_partitioned__year - , subq_8.bridge_account__ds_partitioned__extract_year - , subq_8.bridge_account__ds_partitioned__extract_quarter - , subq_8.bridge_account__ds_partitioned__extract_month - , subq_8.bridge_account__ds_partitioned__extract_day - , subq_8.bridge_account__ds_partitioned__extract_dow - , subq_8.bridge_account__ds_partitioned__extract_doy - , subq_8.ds_partitioned__day AS metric_time__day - , subq_8.ds_partitioned__week AS metric_time__week - , subq_8.ds_partitioned__month AS metric_time__month - , subq_8.ds_partitioned__quarter AS metric_time__quarter - , subq_8.ds_partitioned__year AS metric_time__year - , subq_8.ds_partitioned__extract_year AS metric_time__extract_year - , subq_8.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_8.ds_partitioned__extract_month AS metric_time__extract_month - , subq_8.ds_partitioned__extract_day AS metric_time__extract_day - , subq_8.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_8.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_8.account_id - , subq_8.customer_id - , subq_8.account_id__customer_id - , subq_8.bridge_account__account_id - , subq_8.bridge_account__customer_id - , subq_8.extra_dim - , subq_8.account_id__extra_dim - , subq_8.bridge_account__extra_dim - , subq_8.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_3.account_id__ds_partitioned__week + , subq_3.account_id__ds_partitioned__month + , subq_3.account_id__ds_partitioned__quarter + , subq_3.account_id__ds_partitioned__year + , subq_3.account_id__ds_partitioned__extract_year + , subq_3.account_id__ds_partitioned__extract_quarter + , subq_3.account_id__ds_partitioned__extract_month + , subq_3.account_id__ds_partitioned__extract_day + , subq_3.account_id__ds_partitioned__extract_dow + , subq_3.account_id__ds_partitioned__extract_doy + , subq_3.bridge_account__ds_partitioned__day + , subq_3.bridge_account__ds_partitioned__week + , subq_3.bridge_account__ds_partitioned__month + , subq_3.bridge_account__ds_partitioned__quarter + , subq_3.bridge_account__ds_partitioned__year + , subq_3.bridge_account__ds_partitioned__extract_year + , subq_3.bridge_account__ds_partitioned__extract_quarter + , subq_3.bridge_account__ds_partitioned__extract_month + , subq_3.bridge_account__ds_partitioned__extract_day + , subq_3.bridge_account__ds_partitioned__extract_dow + , subq_3.bridge_account__ds_partitioned__extract_doy + , subq_3.ds_partitioned__day AS metric_time__day + , subq_3.ds_partitioned__week AS metric_time__week + , subq_3.ds_partitioned__month AS metric_time__month + , subq_3.ds_partitioned__quarter AS metric_time__quarter + , subq_3.ds_partitioned__year AS metric_time__year + , subq_3.ds_partitioned__extract_year AS metric_time__extract_year + , subq_3.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_3.ds_partitioned__extract_month AS metric_time__extract_month + , subq_3.ds_partitioned__extract_day AS metric_time__extract_day + , subq_3.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_3.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_3.account_id + , subq_3.customer_id + , subq_3.account_id__customer_id + , subq_3.bridge_account__account_id + , subq_3.bridge_account__customer_id + , subq_3.extra_dim + , subq_3.account_id__extra_dim + , subq_3.bridge_account__extra_dim + , subq_3.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -331,8 +331,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -375,86 +375,86 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.customer_id__ds_partitioned__day - , subq_11.customer_id__ds_partitioned__week - , subq_11.customer_id__ds_partitioned__month - , subq_11.customer_id__ds_partitioned__quarter - , subq_11.customer_id__ds_partitioned__year - , subq_11.customer_id__ds_partitioned__extract_year - , subq_11.customer_id__ds_partitioned__extract_quarter - , subq_11.customer_id__ds_partitioned__extract_month - , subq_11.customer_id__ds_partitioned__extract_day - , subq_11.customer_id__ds_partitioned__extract_dow - , subq_11.customer_id__ds_partitioned__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.customer_id - , subq_11.customer_name - , subq_11.customer_atomic_weight - , subq_11.customer_id__customer_name - , subq_11.customer_id__customer_atomic_weight + 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.customer_id__ds_partitioned__day + , subq_6.customer_id__ds_partitioned__week + , subq_6.customer_id__ds_partitioned__month + , subq_6.customer_id__ds_partitioned__quarter + , subq_6.customer_id__ds_partitioned__year + , subq_6.customer_id__ds_partitioned__extract_year + , subq_6.customer_id__ds_partitioned__extract_quarter + , subq_6.customer_id__ds_partitioned__extract_month + , subq_6.customer_id__ds_partitioned__extract_day + , subq_6.customer_id__ds_partitioned__extract_dow + , subq_6.customer_id__ds_partitioned__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.customer_id + , subq_6.customer_name + , subq_6.customer_atomic_weight + , subq_6.customer_id__customer_name + , subq_6.customer_id__customer_atomic_weight FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - 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.customer_id__ds_partitioned__day - , subq_10.customer_id__ds_partitioned__week - , subq_10.customer_id__ds_partitioned__month - , subq_10.customer_id__ds_partitioned__quarter - , subq_10.customer_id__ds_partitioned__year - , subq_10.customer_id__ds_partitioned__extract_year - , subq_10.customer_id__ds_partitioned__extract_quarter - , subq_10.customer_id__ds_partitioned__extract_month - , subq_10.customer_id__ds_partitioned__extract_day - , subq_10.customer_id__ds_partitioned__extract_dow - , subq_10.customer_id__ds_partitioned__extract_doy - , subq_10.ds_partitioned__day AS metric_time__day - , subq_10.ds_partitioned__week AS metric_time__week - , subq_10.ds_partitioned__month AS metric_time__month - , subq_10.ds_partitioned__quarter AS metric_time__quarter - , subq_10.ds_partitioned__year AS metric_time__year - , subq_10.ds_partitioned__extract_year AS metric_time__extract_year - , subq_10.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_10.ds_partitioned__extract_month AS metric_time__extract_month - , subq_10.ds_partitioned__extract_day AS metric_time__extract_day - , subq_10.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_10.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_10.customer_id - , subq_10.customer_name - , subq_10.customer_atomic_weight - , subq_10.customer_id__customer_name - , subq_10.customer_id__customer_atomic_weight - , subq_10.customers + subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.customer_id__ds_partitioned__day + , subq_5.customer_id__ds_partitioned__week + , subq_5.customer_id__ds_partitioned__month + , subq_5.customer_id__ds_partitioned__quarter + , subq_5.customer_id__ds_partitioned__year + , subq_5.customer_id__ds_partitioned__extract_year + , subq_5.customer_id__ds_partitioned__extract_quarter + , subq_5.customer_id__ds_partitioned__extract_month + , subq_5.customer_id__ds_partitioned__extract_day + , subq_5.customer_id__ds_partitioned__extract_dow + , subq_5.customer_id__ds_partitioned__extract_doy + , subq_5.ds_partitioned__day AS metric_time__day + , subq_5.ds_partitioned__week AS metric_time__week + , subq_5.ds_partitioned__month AS metric_time__month + , subq_5.ds_partitioned__quarter AS metric_time__quarter + , subq_5.ds_partitioned__year AS metric_time__year + , subq_5.ds_partitioned__extract_year AS metric_time__extract_year + , subq_5.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_5.ds_partitioned__extract_month AS metric_time__extract_month + , subq_5.ds_partitioned__extract_day AS metric_time__extract_day + , subq_5.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_5.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_5.customer_id + , subq_5.customer_name + , subq_5.customer_atomic_weight + , subq_5.customer_id__customer_name + , subq_5.customer_id__customer_atomic_weight + , subq_5.customers FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT @@ -487,25 +487,25 @@ FROM ( , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy , customer_table_src_22000.customer_id FROM ***************************.customer_table customer_table_src_22000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_5 + ) subq_6 + ) subq_7 ON ( - subq_9.customer_id = subq_12.customer_id + subq_4.customer_id = subq_7.customer_id ) AND ( - subq_9.ds_partitioned__day = subq_12.ds_partitioned__day + subq_4.ds_partitioned__day = subq_7.ds_partitioned__day ) - ) subq_13 - ) subq_14 + ) subq_8 + ) subq_9 ON ( - subq_7.account_id = subq_14.account_id + subq_2.account_id = subq_9.account_id ) AND ( - subq_7.ds_partitioned__day = subq_14.ds_partitioned__day + subq_2.ds_partitioned__day = subq_9.ds_partitioned__day ) - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 GROUP BY - subq_16.account_id__customer_id__customer_name -) subq_17 + subq_11.account_id__customer_id__customer_name +) subq_12 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql index ba4d2593ef..13473156ca 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_32.customer_id__customer_name AS account_id__customer_id__customer_name + subq_22.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -22,12 +22,12 @@ LEFT OUTER JOIN ( ) AND ( DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) ) -) subq_32 +) subq_22 ON ( - account_month_txns_src_22000.account_id = subq_32.account_id + account_month_txns_src_22000.account_id = subq_22.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_32.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_22.ds_partitioned__day ) GROUP BY - subq_32.customer_id__customer_name + subq_22.customer_id__customer_name diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0.sql index 5abde3de9f..c91380ec59 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0.sql @@ -1,221 +1,221 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_9.bookings) AS bookings - , MAX(subq_15.listings) AS listings + MAX(subq_5.bookings) AS bookings + , MAX(subq_11.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.bookings + subq_4.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_7.bookings) AS bookings + SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_6.bookings + subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -308,165 +308,165 @@ 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_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_6 - ) subq_7 - ) subq_8 -) subq_9 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_2 + ) subq_3 + ) subq_4 +) subq_5 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.listings + subq_10.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_13.listings) AS listings + SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_12.listings + subq_8.listings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.smallest_listing + 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.created_at__day + , subq_7.created_at__week + , subq_7.created_at__month + , subq_7.created_at__quarter + , subq_7.created_at__year + , subq_7.created_at__extract_year + , subq_7.created_at__extract_quarter + , subq_7.created_at__extract_month + , subq_7.created_at__extract_day + , subq_7.created_at__extract_dow + , subq_7.created_at__extract_doy + , subq_7.listing__ds__day + , subq_7.listing__ds__week + , subq_7.listing__ds__month + , subq_7.listing__ds__quarter + , subq_7.listing__ds__year + , subq_7.listing__ds__extract_year + , subq_7.listing__ds__extract_quarter + , subq_7.listing__ds__extract_month + , subq_7.listing__ds__extract_day + , subq_7.listing__ds__extract_dow + , subq_7.listing__ds__extract_doy + , subq_7.listing__created_at__day + , subq_7.listing__created_at__week + , subq_7.listing__created_at__month + , subq_7.listing__created_at__quarter + , subq_7.listing__created_at__year + , subq_7.listing__created_at__extract_year + , subq_7.listing__created_at__extract_quarter + , subq_7.listing__created_at__extract_month + , subq_7.listing__created_at__extract_day + , subq_7.listing__created_at__extract_dow + , subq_7.listing__created_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.user + , subq_7.listing__user + , subq_7.country_latest + , subq_7.is_lux_latest + , subq_7.capacity_latest + , subq_7.listing__country_latest + , subq_7.listing__is_lux_latest + , subq_7.listing__capacity_latest + , subq_7.listings + , subq_7.largest_listing + , subq_7.smallest_listing 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 @@ -527,10 +527,10 @@ CROSS JOIN ( , 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 - WHERE subq_11.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' - ) subq_12 - ) subq_13 - ) subq_14 -) subq_15 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' + ) subq_8 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 265619080c..18ff29de08 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_25.bookings) AS bookings - , MAX(subq_31.listings) AS listings + MAX(subq_17.bookings) AS bookings + , MAX(subq_23.listings) AS listings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -13,7 +13,7 @@ FROM ( SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_25 +) subq_17 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -25,4 +25,4 @@ CROSS JOIN ( SUM(1) AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' -) subq_31 +) subq_23 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0.sql index 8df9db1cbe..1308f664f0 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - 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 + subq_13.metric_time__day + , CAST(subq_13.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_13.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - 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 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) AS metric_time__day + , MAX(subq_7.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_12.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.booking_value AS booking_value_with_is_instant_constraint + subq_6.metric_time__day + , subq_6.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.booking_value) AS booking_value + subq_5.metric_time__day + , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.booking_value + subq_4.metric_time__day + , subq_4.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.booking_value + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.booking_value + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 - ) subq_9 + subq_5.metric_time__day + ) subq_6 + ) subq_7 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.booking_value + subq_11.metric_time__day + , subq_11.booking_value FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.booking_value) AS booking_value + subq_10.metric_time__day + , SUM(subq_10.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.booking_value + subq_9.metric_time__day + , subq_9.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 + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( -- 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_10 - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day - ) subq_13 - ) subq_14 + subq_10.metric_time__day + ) subq_11 + ) subq_12 ON - subq_9.metric_time__day = subq_14.metric_time__day + subq_7.metric_time__day = subq_12.metric_time__day GROUP BY - COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) -) subq_15 + COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) +) subq_13 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0_optimized.sql index a795130ca2..bd85051779 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) AS metric_time__day - , MAX(subq_25.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_30.booking_value) AS booking_value + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) AS metric_time__day + , MAX(subq_21.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_26.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_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_25 + ) subq_21 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_30 + ) subq_26 ON - subq_25.metric_time__day = subq_30.metric_time__day + subq_21.metric_time__day = subq_26.metric_time__day GROUP BY - COALESCE(subq_25.metric_time__day, subq_30.metric_time__day) -) subq_31 + COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) +) subq_27 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0.sql index 70a6055760..601013ec0c 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,236 +1,236 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day + subq_7.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , subq_8.bookings AS delayed_bookings + subq_6.metric_time__day + , subq_6.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_5.metric_time__day + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_4.metric_time__day + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE NOT booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE NOT booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 -) subq_9 + subq_5.metric_time__day + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index 4076d55e53..e23b3a548f 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/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_13 + ) subq_9 WHERE NOT booking__is_instant - ) subq_15 + ) subq_11 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_19 +) subq_15 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0.sql index 5e831037d5..b121adaecf 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_21.metric_time__day - , subq_21.listing__user__home_state_latest - , subq_21.bookings + subq_10.metric_time__day + , subq_10.listing__user__home_state_latest + , subq_10.bookings FROM ( -- Aggregate Measures SELECT - subq_20.metric_time__day - , subq_20.listing__user__home_state_latest - , SUM(subq_20.bookings) AS bookings + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest + , SUM(subq_9.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__home_state_latest', 'metric_time__day'] SELECT - subq_19.metric_time__day - , subq_19.listing__user__home_state_latest - , subq_19.bookings + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest + , subq_8.bookings FROM ( -- Join Standard Outputs SELECT - subq_13.metric_time__day AS metric_time__day - , subq_18.window_start__day AS listing__window_start__day - , subq_18.window_end__day AS listing__window_end__day - , subq_13.listing AS listing - , subq_18.user__home_state_latest AS listing__user__home_state_latest - , subq_13.bookings AS bookings + subq_2.metric_time__day AS metric_time__day + , subq_7.window_start__day AS listing__window_start__day + , subq_7.window_end__day AS listing__window_end__day + , subq_2.listing AS listing + , subq_7.user__home_state_latest AS listing__user__home_state_latest + , subq_2.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_12.metric_time__day - , subq_12.listing - , subq_12.bookings + subq_1.metric_time__day + , subq_1.listing + , subq_1.bookings FROM ( -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.paid_at__day - , subq_11.paid_at__week - , subq_11.paid_at__month - , subq_11.paid_at__quarter - , subq_11.paid_at__year - , subq_11.paid_at__extract_year - , subq_11.paid_at__extract_quarter - , subq_11.paid_at__extract_month - , subq_11.paid_at__extract_day - , subq_11.paid_at__extract_dow - , subq_11.paid_at__extract_doy - , subq_11.booking__ds__day - , subq_11.booking__ds__week - , subq_11.booking__ds__month - , subq_11.booking__ds__quarter - , subq_11.booking__ds__year - , subq_11.booking__ds__extract_year - , subq_11.booking__ds__extract_quarter - , subq_11.booking__ds__extract_month - , subq_11.booking__ds__extract_day - , subq_11.booking__ds__extract_dow - , subq_11.booking__ds__extract_doy - , subq_11.booking__ds_partitioned__day - , subq_11.booking__ds_partitioned__week - , subq_11.booking__ds_partitioned__month - , subq_11.booking__ds_partitioned__quarter - , subq_11.booking__ds_partitioned__year - , subq_11.booking__ds_partitioned__extract_year - , subq_11.booking__ds_partitioned__extract_quarter - , subq_11.booking__ds_partitioned__extract_month - , subq_11.booking__ds_partitioned__extract_day - , subq_11.booking__ds_partitioned__extract_dow - , subq_11.booking__ds_partitioned__extract_doy - , subq_11.booking__paid_at__day - , subq_11.booking__paid_at__week - , subq_11.booking__paid_at__month - , subq_11.booking__paid_at__quarter - , subq_11.booking__paid_at__year - , subq_11.booking__paid_at__extract_year - , subq_11.booking__paid_at__extract_quarter - , subq_11.booking__paid_at__extract_month - , subq_11.booking__paid_at__extract_day - , subq_11.booking__paid_at__extract_dow - , subq_11.booking__paid_at__extract_doy - , subq_11.ds__day AS metric_time__day - , subq_11.ds__week AS metric_time__week - , subq_11.ds__month AS metric_time__month - , subq_11.ds__quarter AS metric_time__quarter - , subq_11.ds__year AS metric_time__year - , subq_11.ds__extract_year AS metric_time__extract_year - , subq_11.ds__extract_quarter AS metric_time__extract_quarter - , subq_11.ds__extract_month AS metric_time__extract_month - , subq_11.ds__extract_day AS metric_time__extract_day - , subq_11.ds__extract_dow AS metric_time__extract_dow - , subq_11.ds__extract_doy AS metric_time__extract_doy - , subq_11.listing - , subq_11.guest - , subq_11.host - , subq_11.user - , subq_11.booking__listing - , subq_11.booking__guest - , subq_11.booking__host - , subq_11.booking__user - , subq_11.is_instant - , subq_11.booking__is_instant - , subq_11.bookings - , subq_11.instant_bookings - , subq_11.booking_value - , subq_11.bookers - , subq_11.average_booking_value + 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.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,84 +211,84 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_11 - ) subq_12 - ) subq_13 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] SELECT - subq_17.window_start__day - , subq_17.window_end__day - , subq_17.listing - , subq_17.user__home_state_latest + subq_6.window_start__day + , subq_6.window_end__day + , subq_6.listing + , subq_6.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_14.window_start__day AS window_start__day - , subq_14.window_start__week AS window_start__week - , subq_14.window_start__month AS window_start__month - , subq_14.window_start__quarter AS window_start__quarter - , subq_14.window_start__year AS window_start__year - , subq_14.window_start__extract_year AS window_start__extract_year - , subq_14.window_start__extract_quarter AS window_start__extract_quarter - , subq_14.window_start__extract_month AS window_start__extract_month - , subq_14.window_start__extract_day AS window_start__extract_day - , subq_14.window_start__extract_dow AS window_start__extract_dow - , subq_14.window_start__extract_doy AS window_start__extract_doy - , subq_14.window_end__day AS window_end__day - , subq_14.window_end__week AS window_end__week - , subq_14.window_end__month AS window_end__month - , subq_14.window_end__quarter AS window_end__quarter - , subq_14.window_end__year AS window_end__year - , subq_14.window_end__extract_year AS window_end__extract_year - , subq_14.window_end__extract_quarter AS window_end__extract_quarter - , subq_14.window_end__extract_month AS window_end__extract_month - , subq_14.window_end__extract_day AS window_end__extract_day - , subq_14.window_end__extract_dow AS window_end__extract_dow - , subq_14.window_end__extract_doy AS window_end__extract_doy - , subq_14.listing__window_start__day AS listing__window_start__day - , subq_14.listing__window_start__week AS listing__window_start__week - , subq_14.listing__window_start__month AS listing__window_start__month - , subq_14.listing__window_start__quarter AS listing__window_start__quarter - , subq_14.listing__window_start__year AS listing__window_start__year - , subq_14.listing__window_start__extract_year AS listing__window_start__extract_year - , subq_14.listing__window_start__extract_quarter AS listing__window_start__extract_quarter - , subq_14.listing__window_start__extract_month AS listing__window_start__extract_month - , subq_14.listing__window_start__extract_day AS listing__window_start__extract_day - , subq_14.listing__window_start__extract_dow AS listing__window_start__extract_dow - , subq_14.listing__window_start__extract_doy AS listing__window_start__extract_doy - , subq_14.listing__window_end__day AS listing__window_end__day - , subq_14.listing__window_end__week AS listing__window_end__week - , subq_14.listing__window_end__month AS listing__window_end__month - , subq_14.listing__window_end__quarter AS listing__window_end__quarter - , subq_14.listing__window_end__year AS listing__window_end__year - , subq_14.listing__window_end__extract_year AS listing__window_end__extract_year - , subq_14.listing__window_end__extract_quarter AS listing__window_end__extract_quarter - , subq_14.listing__window_end__extract_month AS listing__window_end__extract_month - , subq_14.listing__window_end__extract_day AS listing__window_end__extract_day - , subq_14.listing__window_end__extract_dow AS listing__window_end__extract_dow - , subq_14.listing__window_end__extract_doy AS listing__window_end__extract_doy - , subq_16.ds__day AS user__ds__day - , subq_16.ds__week AS user__ds__week - , subq_16.ds__month AS user__ds__month - , subq_16.ds__quarter AS user__ds__quarter - , subq_16.ds__year AS user__ds__year - , subq_16.ds__extract_year AS user__ds__extract_year - , subq_16.ds__extract_quarter AS user__ds__extract_quarter - , subq_16.ds__extract_month AS user__ds__extract_month - , subq_16.ds__extract_day AS user__ds__extract_day - , subq_16.ds__extract_dow AS user__ds__extract_dow - , subq_16.ds__extract_doy AS user__ds__extract_doy - , subq_14.listing AS listing - , subq_14.user AS user - , subq_14.listing__user AS listing__user - , subq_14.country AS country - , subq_14.is_lux AS is_lux - , subq_14.capacity AS capacity - , subq_14.listing__country AS listing__country - , subq_14.listing__is_lux AS listing__is_lux - , subq_14.listing__capacity AS listing__capacity - , subq_16.home_state_latest AS user__home_state_latest + subq_3.window_start__day AS window_start__day + , subq_3.window_start__week AS window_start__week + , subq_3.window_start__month AS window_start__month + , subq_3.window_start__quarter AS window_start__quarter + , subq_3.window_start__year AS window_start__year + , subq_3.window_start__extract_year AS window_start__extract_year + , subq_3.window_start__extract_quarter AS window_start__extract_quarter + , subq_3.window_start__extract_month AS window_start__extract_month + , subq_3.window_start__extract_day AS window_start__extract_day + , subq_3.window_start__extract_dow AS window_start__extract_dow + , subq_3.window_start__extract_doy AS window_start__extract_doy + , subq_3.window_end__day AS window_end__day + , subq_3.window_end__week AS window_end__week + , subq_3.window_end__month AS window_end__month + , subq_3.window_end__quarter AS window_end__quarter + , subq_3.window_end__year AS window_end__year + , subq_3.window_end__extract_year AS window_end__extract_year + , subq_3.window_end__extract_quarter AS window_end__extract_quarter + , subq_3.window_end__extract_month AS window_end__extract_month + , subq_3.window_end__extract_day AS window_end__extract_day + , subq_3.window_end__extract_dow AS window_end__extract_dow + , subq_3.window_end__extract_doy AS window_end__extract_doy + , subq_3.listing__window_start__day AS listing__window_start__day + , subq_3.listing__window_start__week AS listing__window_start__week + , subq_3.listing__window_start__month AS listing__window_start__month + , subq_3.listing__window_start__quarter AS listing__window_start__quarter + , subq_3.listing__window_start__year AS listing__window_start__year + , subq_3.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_3.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_3.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_3.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_3.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_3.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_3.listing__window_end__day AS listing__window_end__day + , subq_3.listing__window_end__week AS listing__window_end__week + , subq_3.listing__window_end__month AS listing__window_end__month + , subq_3.listing__window_end__quarter AS listing__window_end__quarter + , subq_3.listing__window_end__year AS listing__window_end__year + , subq_3.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_3.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_3.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_3.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_3.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_3.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_5.ds__day AS user__ds__day + , subq_5.ds__week AS user__ds__week + , subq_5.ds__month AS user__ds__month + , subq_5.ds__quarter AS user__ds__quarter + , subq_5.ds__year AS user__ds__year + , subq_5.ds__extract_year AS user__ds__extract_year + , subq_5.ds__extract_quarter AS user__ds__extract_quarter + , subq_5.ds__extract_month AS user__ds__extract_month + , subq_5.ds__extract_day AS user__ds__extract_day + , subq_5.ds__extract_dow AS user__ds__extract_dow + , subq_5.ds__extract_doy AS user__ds__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country AS country + , subq_3.is_lux AS is_lux + , subq_3.capacity AS capacity + , subq_3.listing__country AS listing__country + , subq_3.listing__is_lux AS listing__is_lux + , subq_3.listing__capacity AS listing__capacity + , subq_5.home_state_latest AS user__home_state_latest FROM ( -- Read Elements From Semantic Model 'listings' SELECT @@ -346,7 +346,7 @@ FROM ( , listings_src_26000.user_id AS user , listings_src_26000.user_id AS listing__user FROM ***************************.dim_listings listings_src_26000 - ) subq_14 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,31 +376,31 @@ FROM ( -- 'user', -- ] SELECT - subq_15.ds__day - , subq_15.ds__week - , subq_15.ds__month - , subq_15.ds__quarter - , subq_15.ds__year - , subq_15.ds__extract_year - , subq_15.ds__extract_quarter - , subq_15.ds__extract_month - , subq_15.ds__extract_day - , subq_15.ds__extract_dow - , subq_15.ds__extract_doy - , subq_15.user__ds__day - , subq_15.user__ds__week - , subq_15.user__ds__month - , subq_15.user__ds__quarter - , subq_15.user__ds__year - , subq_15.user__ds__extract_year - , subq_15.user__ds__extract_quarter - , subq_15.user__ds__extract_month - , subq_15.user__ds__extract_day - , subq_15.user__ds__extract_dow - , subq_15.user__ds__extract_doy - , subq_15.user - , subq_15.home_state_latest - , subq_15.user__home_state_latest + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.user__ds__day + , subq_4.user__ds__week + , subq_4.user__ds__month + , subq_4.user__ds__quarter + , subq_4.user__ds__year + , subq_4.user__ds__extract_year + , subq_4.user__ds__extract_quarter + , subq_4.user__ds__extract_month + , subq_4.user__ds__extract_day + , subq_4.user__ds__extract_dow + , subq_4.user__ds__extract_doy + , subq_4.user + , subq_4.home_state_latest + , subq_4.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -430,29 +430,29 @@ FROM ( , users_latest_src_26000.home_state_latest AS user__home_state_latest , users_latest_src_26000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_26000 - ) subq_15 - ) subq_16 + ) subq_4 + ) subq_5 ON - subq_14.user = subq_16.user - ) subq_17 - ) subq_18 + subq_3.user = subq_5.user + ) subq_6 + ) subq_7 ON ( - subq_13.listing = subq_18.listing + subq_2.listing = subq_7.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_2.metric_time__day >= subq_7.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_2.metric_time__day < subq_7.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_7.window_end__day IS NULL ) ) ) - ) subq_19 - ) subq_20 + ) subq_8 + ) subq_9 GROUP BY - subq_20.metric_time__day - , subq_20.listing__user__home_state_latest -) subq_21 + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest +) subq_10 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0_optimized.sql index ad6481bf38..43c459ada2 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_35.metric_time__day AS metric_time__day - , subq_40.user__home_state_latest AS listing__user__home_state_latest - , SUM(subq_35.bookings) AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_18.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,7 +15,7 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_35 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] @@ -29,21 +29,21 @@ LEFT OUTER JOIN ( ***************************.dim_users_latest users_latest_src_26000 ON listings_src_26000.user_id = users_latest_src_26000.user_id -) subq_40 +) subq_18 ON ( - subq_35.listing = subq_40.listing + subq_13.listing = subq_18.listing ) AND ( ( - subq_35.metric_time__day >= subq_40.window_start__day + subq_13.metric_time__day >= subq_18.window_start__day ) AND ( ( - subq_35.metric_time__day < subq_40.window_end__day + subq_13.metric_time__day < subq_18.window_end__day ) OR ( - subq_40.window_end__day IS NULL + subq_18.window_end__day IS NULL ) ) ) GROUP BY - subq_35.metric_time__day - , subq_40.user__home_state_latest + subq_13.metric_time__day + , subq_18.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0.sql index d014e6aba2..6b614251bf 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,130 +1,130 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__lux_listing__is_confirmed_lux - , subq_13.bookings + subq_10.metric_time__day + , subq_10.listing__lux_listing__is_confirmed_lux + , subq_10.bookings FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.listing__lux_listing__is_confirmed_lux - , SUM(subq_12.bookings) AS bookings + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux + , SUM(subq_9.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__lux_listing__is_confirmed_lux', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listing__lux_listing__is_confirmed_lux - , subq_11.bookings + subq_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux + , subq_8.bookings FROM ( -- Join Standard Outputs SELECT - subq_5.metric_time__day AS metric_time__day - , subq_10.lux_listing__window_start__day AS listing__lux_listing__window_start__day - , subq_10.lux_listing__window_end__day AS listing__lux_listing__window_end__day - , subq_5.listing AS listing - , subq_10.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , subq_5.bookings AS bookings + subq_2.metric_time__day AS metric_time__day + , subq_7.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_7.lux_listing__window_end__day AS listing__lux_listing__window_end__day + , subq_2.listing AS listing + , subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_2.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT - subq_4.metric_time__day - , subq_4.listing - , subq_4.bookings + subq_1.metric_time__day + , subq_1.listing + , subq_1.bookings 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_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.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.listing - , subq_3.guest - , subq_3.host - , subq_3.user - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.booking__user - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.bookers - , subq_3.average_booking_value + 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.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -211,45 +211,45 @@ FROM ( , bookings_source_src_26000.host_id AS booking__host , bookings_source_src_26000.guest_id AS booking__user FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] SELECT - subq_9.lux_listing__window_start__day - , subq_9.lux_listing__window_end__day - , subq_9.listing - , subq_9.lux_listing__is_confirmed_lux + subq_6.lux_listing__window_start__day + , subq_6.lux_listing__window_end__day + , subq_6.listing + , subq_6.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_8.window_start__day AS lux_listing__window_start__day - , subq_8.window_start__week AS lux_listing__window_start__week - , subq_8.window_start__month AS lux_listing__window_start__month - , subq_8.window_start__quarter AS lux_listing__window_start__quarter - , subq_8.window_start__year AS lux_listing__window_start__year - , subq_8.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_8.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_8.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_8.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_8.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_8.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_8.window_end__day AS lux_listing__window_end__day - , subq_8.window_end__week AS lux_listing__window_end__week - , subq_8.window_end__month AS lux_listing__window_end__month - , subq_8.window_end__quarter AS lux_listing__window_end__quarter - , subq_8.window_end__year AS lux_listing__window_end__year - , subq_8.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_8.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_8.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_8.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_8.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_8.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_6.listing AS listing - , subq_6.lux_listing AS lux_listing - , subq_6.listing__lux_listing AS listing__lux_listing - , subq_8.is_confirmed_lux AS lux_listing__is_confirmed_lux + subq_5.window_start__day AS lux_listing__window_start__day + , subq_5.window_start__week AS lux_listing__window_start__week + , subq_5.window_start__month AS lux_listing__window_start__month + , subq_5.window_start__quarter AS lux_listing__window_start__quarter + , subq_5.window_start__year AS lux_listing__window_start__year + , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_5.window_end__day AS lux_listing__window_end__day + , subq_5.window_end__week AS lux_listing__window_end__week + , subq_5.window_end__month AS lux_listing__window_end__month + , subq_5.window_end__quarter AS lux_listing__window_end__quarter + , subq_5.window_end__year AS lux_listing__window_end__year + , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_3.listing AS listing + , subq_3.lux_listing AS lux_listing + , subq_3.listing__lux_listing AS listing__lux_listing + , subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -257,7 +257,7 @@ FROM ( , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 - ) subq_6 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,53 +309,53 @@ FROM ( -- 'lux_listing', -- ] SELECT - subq_7.window_start__day - , subq_7.window_start__week - , subq_7.window_start__month - , subq_7.window_start__quarter - , subq_7.window_start__year - , subq_7.window_start__extract_year - , subq_7.window_start__extract_quarter - , subq_7.window_start__extract_month - , subq_7.window_start__extract_day - , subq_7.window_start__extract_dow - , subq_7.window_start__extract_doy - , subq_7.window_end__day - , subq_7.window_end__week - , subq_7.window_end__month - , subq_7.window_end__quarter - , subq_7.window_end__year - , subq_7.window_end__extract_year - , subq_7.window_end__extract_quarter - , subq_7.window_end__extract_month - , subq_7.window_end__extract_day - , subq_7.window_end__extract_dow - , subq_7.window_end__extract_doy - , subq_7.lux_listing__window_start__day - , subq_7.lux_listing__window_start__week - , subq_7.lux_listing__window_start__month - , subq_7.lux_listing__window_start__quarter - , subq_7.lux_listing__window_start__year - , subq_7.lux_listing__window_start__extract_year - , subq_7.lux_listing__window_start__extract_quarter - , subq_7.lux_listing__window_start__extract_month - , subq_7.lux_listing__window_start__extract_day - , subq_7.lux_listing__window_start__extract_dow - , subq_7.lux_listing__window_start__extract_doy - , subq_7.lux_listing__window_end__day - , subq_7.lux_listing__window_end__week - , subq_7.lux_listing__window_end__month - , subq_7.lux_listing__window_end__quarter - , subq_7.lux_listing__window_end__year - , subq_7.lux_listing__window_end__extract_year - , subq_7.lux_listing__window_end__extract_quarter - , subq_7.lux_listing__window_end__extract_month - , subq_7.lux_listing__window_end__extract_day - , subq_7.lux_listing__window_end__extract_dow - , subq_7.lux_listing__window_end__extract_doy - , subq_7.lux_listing - , subq_7.is_confirmed_lux - , subq_7.lux_listing__is_confirmed_lux + subq_4.window_start__day + , subq_4.window_start__week + , subq_4.window_start__month + , subq_4.window_start__quarter + , subq_4.window_start__year + , subq_4.window_start__extract_year + , subq_4.window_start__extract_quarter + , subq_4.window_start__extract_month + , subq_4.window_start__extract_day + , subq_4.window_start__extract_dow + , subq_4.window_start__extract_doy + , subq_4.window_end__day + , subq_4.window_end__week + , subq_4.window_end__month + , subq_4.window_end__quarter + , subq_4.window_end__year + , subq_4.window_end__extract_year + , subq_4.window_end__extract_quarter + , subq_4.window_end__extract_month + , subq_4.window_end__extract_day + , subq_4.window_end__extract_dow + , subq_4.window_end__extract_doy + , subq_4.lux_listing__window_start__day + , subq_4.lux_listing__window_start__week + , subq_4.lux_listing__window_start__month + , subq_4.lux_listing__window_start__quarter + , subq_4.lux_listing__window_start__year + , subq_4.lux_listing__window_start__extract_year + , subq_4.lux_listing__window_start__extract_quarter + , subq_4.lux_listing__window_start__extract_month + , subq_4.lux_listing__window_start__extract_day + , subq_4.lux_listing__window_start__extract_dow + , subq_4.lux_listing__window_start__extract_doy + , subq_4.lux_listing__window_end__day + , subq_4.lux_listing__window_end__week + , subq_4.lux_listing__window_end__month + , subq_4.lux_listing__window_end__quarter + , subq_4.lux_listing__window_end__year + , subq_4.lux_listing__window_end__extract_year + , subq_4.lux_listing__window_end__extract_quarter + , subq_4.lux_listing__window_end__extract_month + , subq_4.lux_listing__window_end__extract_day + , subq_4.lux_listing__window_end__extract_dow + , subq_4.lux_listing__window_end__extract_doy + , subq_4.lux_listing + , subq_4.is_confirmed_lux + , subq_4.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT @@ -407,29 +407,29 @@ FROM ( , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux , lux_listings_src_26000.lux_listing_id AS lux_listing FROM ***************************.dim_lux_listings lux_listings_src_26000 - ) subq_7 - ) subq_8 + ) subq_4 + ) subq_5 ON - subq_6.lux_listing = subq_8.lux_listing - ) subq_9 - ) subq_10 + subq_3.lux_listing = subq_5.lux_listing + ) subq_6 + ) subq_7 ON ( - subq_5.listing = subq_10.listing + subq_2.listing = subq_7.listing ) AND ( ( - subq_5.metric_time__day >= subq_10.lux_listing__window_start__day + subq_2.metric_time__day >= subq_7.lux_listing__window_start__day ) AND ( ( - subq_5.metric_time__day < subq_10.lux_listing__window_end__day + subq_2.metric_time__day < subq_7.lux_listing__window_end__day ) OR ( - subq_10.lux_listing__window_end__day IS NULL + subq_7.lux_listing__window_end__day IS NULL ) ) ) - ) subq_11 - ) subq_12 + ) subq_8 + ) subq_9 GROUP BY - subq_12.metric_time__day - , subq_12.listing__lux_listing__is_confirmed_lux -) subq_13 + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux +) subq_10 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0_optimized.sql index eaaa8aa132..d0d6125e14 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,9 +3,9 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_19.metric_time__day AS metric_time__day - , subq_24.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , SUM(subq_19.bookings) AS bookings + subq_13.metric_time__day AS metric_time__day + , subq_18.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -15,7 +15,7 @@ FROM ( , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_19 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] @@ -29,21 +29,21 @@ LEFT OUTER JOIN ( ***************************.dim_lux_listings lux_listings_src_26000 ON lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id -) subq_24 +) subq_18 ON ( - subq_19.listing = subq_24.listing + subq_13.listing = subq_18.listing ) AND ( ( - subq_19.metric_time__day >= subq_24.lux_listing__window_start__day + subq_13.metric_time__day >= subq_18.lux_listing__window_start__day ) AND ( ( - subq_19.metric_time__day < subq_24.lux_listing__window_end__day + subq_13.metric_time__day < subq_18.lux_listing__window_end__day ) OR ( - subq_24.lux_listing__window_end__day IS NULL + subq_18.lux_listing__window_end__day IS NULL ) ) ) GROUP BY - subq_19.metric_time__day - , subq_24.lux_listing__is_confirmed_lux + subq_13.metric_time__day + , subq_18.lux_listing__is_confirmed_lux diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0.sql index 39ee9a9bdf..e5a563d88a 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0.sql @@ -1,93 +1,93 @@ -- Compute Metrics via Expressions SELECT - subq_17.account_id__customer_id__customer_name - , subq_17.txn_count + subq_12.account_id__customer_id__customer_name + , subq_12.txn_count FROM ( -- Aggregate Measures SELECT - subq_16.account_id__customer_id__customer_name - , SUM(subq_16.txn_count) AS txn_count + subq_11.account_id__customer_id__customer_name + , SUM(subq_11.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_15.account_id__customer_id__customer_name - , subq_15.txn_count + subq_10.account_id__customer_id__customer_name + , subq_10.txn_count FROM ( -- Join Standard Outputs SELECT - subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_14.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_7.account_id AS account_id - , subq_14.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_7.txn_count AS txn_count + subq_2.ds_partitioned__day AS ds_partitioned__day + , subq_9.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_2.account_id AS account_id + , subq_9.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_2.txn_count AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] SELECT - subq_6.ds_partitioned__day - , subq_6.account_id - , subq_6.txn_count + subq_1.ds_partitioned__day + , subq_1.account_id + , subq_1.txn_count FROM ( -- Metric Time Dimension 'ds' SELECT - subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.account_id__ds_partitioned__day - , subq_5.account_id__ds_partitioned__week - , subq_5.account_id__ds_partitioned__month - , subq_5.account_id__ds_partitioned__quarter - , subq_5.account_id__ds_partitioned__year - , subq_5.account_id__ds_partitioned__extract_year - , subq_5.account_id__ds_partitioned__extract_quarter - , subq_5.account_id__ds_partitioned__extract_month - , subq_5.account_id__ds_partitioned__extract_day - , subq_5.account_id__ds_partitioned__extract_dow - , subq_5.account_id__ds_partitioned__extract_doy - , subq_5.account_id__ds__day - , subq_5.account_id__ds__week - , subq_5.account_id__ds__month - , subq_5.account_id__ds__quarter - , subq_5.account_id__ds__year - , subq_5.account_id__ds__extract_year - , subq_5.account_id__ds__extract_quarter - , subq_5.account_id__ds__extract_month - , subq_5.account_id__ds__extract_day - , subq_5.account_id__ds__extract_dow - , subq_5.account_id__ds__extract_doy - , subq_5.ds__day AS metric_time__day - , subq_5.ds__week AS metric_time__week - , subq_5.ds__month AS metric_time__month - , subq_5.ds__quarter AS metric_time__quarter - , subq_5.ds__year AS metric_time__year - , subq_5.ds__extract_year AS metric_time__extract_year - , subq_5.ds__extract_quarter AS metric_time__extract_quarter - , subq_5.ds__extract_month AS metric_time__extract_month - , subq_5.ds__extract_day AS metric_time__extract_day - , subq_5.ds__extract_dow AS metric_time__extract_dow - , subq_5.ds__extract_doy AS metric_time__extract_doy - , subq_5.account_id - , subq_5.account_month - , subq_5.account_id__account_month - , subq_5.txn_count + 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.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.account_id__ds_partitioned__day + , subq_0.account_id__ds_partitioned__week + , subq_0.account_id__ds_partitioned__month + , subq_0.account_id__ds_partitioned__quarter + , subq_0.account_id__ds_partitioned__year + , subq_0.account_id__ds_partitioned__extract_year + , subq_0.account_id__ds_partitioned__extract_quarter + , subq_0.account_id__ds_partitioned__extract_month + , subq_0.account_id__ds_partitioned__extract_day + , subq_0.account_id__ds_partitioned__extract_dow + , subq_0.account_id__ds_partitioned__extract_doy + , subq_0.account_id__ds__day + , subq_0.account_id__ds__week + , subq_0.account_id__ds__month + , subq_0.account_id__ds__quarter + , subq_0.account_id__ds__year + , subq_0.account_id__ds__extract_year + , subq_0.account_id__ds__extract_quarter + , subq_0.account_id__ds__extract_month + , subq_0.account_id__ds__extract_day + , subq_0.account_id__ds__extract_dow + , subq_0.account_id__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.account_id + , subq_0.account_month + , subq_0.account_id__account_month + , subq_0.txn_count FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT @@ -140,151 +140,151 @@ FROM ( , account_month_txns_src_22000.account_month AS account_id__account_month , account_month_txns_src_22000.account_id FROM ***************************.account_month_txns account_month_txns_src_22000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_0 + ) subq_1 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_13.ds_partitioned__day - , subq_13.account_id - , subq_13.customer_id__customer_name + subq_8.ds_partitioned__day + , subq_8.account_id + , subq_8.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_9.ds_partitioned__day AS ds_partitioned__day - , subq_9.ds_partitioned__week AS ds_partitioned__week - , subq_9.ds_partitioned__month AS ds_partitioned__month - , subq_9.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_9.ds_partitioned__year AS ds_partitioned__year - , subq_9.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_9.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_9.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_9.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_9.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_9.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_9.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_9.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_9.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_9.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_9.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_9.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_9.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_9.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_9.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_9.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_9.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_9.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_9.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_9.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_9.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_9.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_9.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_9.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_9.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_9.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_9.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_9.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_9.metric_time__day AS metric_time__day - , subq_9.metric_time__week AS metric_time__week - , subq_9.metric_time__month AS metric_time__month - , subq_9.metric_time__quarter AS metric_time__quarter - , subq_9.metric_time__year AS metric_time__year - , subq_9.metric_time__extract_year AS metric_time__extract_year - , subq_9.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_9.metric_time__extract_month AS metric_time__extract_month - , subq_9.metric_time__extract_day AS metric_time__extract_day - , subq_9.metric_time__extract_dow AS metric_time__extract_dow - , subq_9.metric_time__extract_doy AS metric_time__extract_doy - , subq_12.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_12.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_12.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_12.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_12.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_12.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_12.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_12.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_12.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_12.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_12.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_12.metric_time__day AS customer_id__metric_time__day - , subq_12.metric_time__week AS customer_id__metric_time__week - , subq_12.metric_time__month AS customer_id__metric_time__month - , subq_12.metric_time__quarter AS customer_id__metric_time__quarter - , subq_12.metric_time__year AS customer_id__metric_time__year - , subq_12.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_12.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_12.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_12.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_12.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_12.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_9.account_id AS account_id - , subq_9.customer_id AS customer_id - , subq_9.account_id__customer_id AS account_id__customer_id - , subq_9.bridge_account__account_id AS bridge_account__account_id - , subq_9.bridge_account__customer_id AS bridge_account__customer_id - , subq_9.extra_dim AS extra_dim - , subq_9.account_id__extra_dim AS account_id__extra_dim - , subq_9.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_12.customer_name AS customer_id__customer_name - , subq_12.customer_atomic_weight AS customer_id__customer_atomic_weight - , subq_9.account_customer_combos AS account_customer_combos + subq_4.ds_partitioned__day AS ds_partitioned__day + , subq_4.ds_partitioned__week AS ds_partitioned__week + , subq_4.ds_partitioned__month AS ds_partitioned__month + , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_4.ds_partitioned__year AS ds_partitioned__year + , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_4.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_4.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_4.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_4.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_4.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_4.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_4.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_4.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_4.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_4.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_4.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_4.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_4.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_4.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_4.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_4.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_4.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_4.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_4.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_4.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_4.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_4.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_4.metric_time__day AS metric_time__day + , subq_4.metric_time__week AS metric_time__week + , subq_4.metric_time__month AS metric_time__month + , subq_4.metric_time__quarter AS metric_time__quarter + , subq_4.metric_time__year AS metric_time__year + , subq_4.metric_time__extract_year AS metric_time__extract_year + , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_4.metric_time__extract_month AS metric_time__extract_month + , subq_4.metric_time__extract_day AS metric_time__extract_day + , subq_4.metric_time__extract_dow AS metric_time__extract_dow + , subq_4.metric_time__extract_doy AS metric_time__extract_doy + , subq_7.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_7.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_7.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_7.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_7.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_7.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_7.metric_time__day AS customer_id__metric_time__day + , subq_7.metric_time__week AS customer_id__metric_time__week + , subq_7.metric_time__month AS customer_id__metric_time__month + , subq_7.metric_time__quarter AS customer_id__metric_time__quarter + , subq_7.metric_time__year AS customer_id__metric_time__year + , subq_7.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_7.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_7.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_7.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_7.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_7.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_4.account_id AS account_id + , subq_4.customer_id AS customer_id + , subq_4.account_id__customer_id AS account_id__customer_id + , subq_4.bridge_account__account_id AS bridge_account__account_id + , subq_4.bridge_account__customer_id AS bridge_account__customer_id + , subq_4.extra_dim AS extra_dim + , subq_4.account_id__extra_dim AS account_id__extra_dim + , subq_4.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_7.customer_name AS customer_id__customer_name + , subq_7.customer_atomic_weight AS customer_id__customer_atomic_weight + , subq_4.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_8.ds_partitioned__day - , subq_8.ds_partitioned__week - , subq_8.ds_partitioned__month - , subq_8.ds_partitioned__quarter - , subq_8.ds_partitioned__year - , subq_8.ds_partitioned__extract_year - , subq_8.ds_partitioned__extract_quarter - , subq_8.ds_partitioned__extract_month - , subq_8.ds_partitioned__extract_day - , subq_8.ds_partitioned__extract_dow - , subq_8.ds_partitioned__extract_doy - , subq_8.account_id__ds_partitioned__day - , subq_8.account_id__ds_partitioned__week - , subq_8.account_id__ds_partitioned__month - , subq_8.account_id__ds_partitioned__quarter - , subq_8.account_id__ds_partitioned__year - , subq_8.account_id__ds_partitioned__extract_year - , subq_8.account_id__ds_partitioned__extract_quarter - , subq_8.account_id__ds_partitioned__extract_month - , subq_8.account_id__ds_partitioned__extract_day - , subq_8.account_id__ds_partitioned__extract_dow - , subq_8.account_id__ds_partitioned__extract_doy - , subq_8.bridge_account__ds_partitioned__day - , subq_8.bridge_account__ds_partitioned__week - , subq_8.bridge_account__ds_partitioned__month - , subq_8.bridge_account__ds_partitioned__quarter - , subq_8.bridge_account__ds_partitioned__year - , subq_8.bridge_account__ds_partitioned__extract_year - , subq_8.bridge_account__ds_partitioned__extract_quarter - , subq_8.bridge_account__ds_partitioned__extract_month - , subq_8.bridge_account__ds_partitioned__extract_day - , subq_8.bridge_account__ds_partitioned__extract_dow - , subq_8.bridge_account__ds_partitioned__extract_doy - , subq_8.ds_partitioned__day AS metric_time__day - , subq_8.ds_partitioned__week AS metric_time__week - , subq_8.ds_partitioned__month AS metric_time__month - , subq_8.ds_partitioned__quarter AS metric_time__quarter - , subq_8.ds_partitioned__year AS metric_time__year - , subq_8.ds_partitioned__extract_year AS metric_time__extract_year - , subq_8.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_8.ds_partitioned__extract_month AS metric_time__extract_month - , subq_8.ds_partitioned__extract_day AS metric_time__extract_day - , subq_8.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_8.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_8.account_id - , subq_8.customer_id - , subq_8.account_id__customer_id - , subq_8.bridge_account__account_id - , subq_8.bridge_account__customer_id - , subq_8.extra_dim - , subq_8.account_id__extra_dim - , subq_8.bridge_account__extra_dim - , subq_8.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_3.account_id__ds_partitioned__week + , subq_3.account_id__ds_partitioned__month + , subq_3.account_id__ds_partitioned__quarter + , subq_3.account_id__ds_partitioned__year + , subq_3.account_id__ds_partitioned__extract_year + , subq_3.account_id__ds_partitioned__extract_quarter + , subq_3.account_id__ds_partitioned__extract_month + , subq_3.account_id__ds_partitioned__extract_day + , subq_3.account_id__ds_partitioned__extract_dow + , subq_3.account_id__ds_partitioned__extract_doy + , subq_3.bridge_account__ds_partitioned__day + , subq_3.bridge_account__ds_partitioned__week + , subq_3.bridge_account__ds_partitioned__month + , subq_3.bridge_account__ds_partitioned__quarter + , subq_3.bridge_account__ds_partitioned__year + , subq_3.bridge_account__ds_partitioned__extract_year + , subq_3.bridge_account__ds_partitioned__extract_quarter + , subq_3.bridge_account__ds_partitioned__extract_month + , subq_3.bridge_account__ds_partitioned__extract_day + , subq_3.bridge_account__ds_partitioned__extract_dow + , subq_3.bridge_account__ds_partitioned__extract_doy + , subq_3.ds_partitioned__day AS metric_time__day + , subq_3.ds_partitioned__week AS metric_time__week + , subq_3.ds_partitioned__month AS metric_time__month + , subq_3.ds_partitioned__quarter AS metric_time__quarter + , subq_3.ds_partitioned__year AS metric_time__year + , subq_3.ds_partitioned__extract_year AS metric_time__extract_year + , subq_3.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_3.ds_partitioned__extract_month AS metric_time__extract_month + , subq_3.ds_partitioned__extract_day AS metric_time__extract_day + , subq_3.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_3.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_3.account_id + , subq_3.customer_id + , subq_3.account_id__customer_id + , subq_3.bridge_account__account_id + , subq_3.bridge_account__customer_id + , subq_3.extra_dim + , subq_3.account_id__extra_dim + , subq_3.bridge_account__extra_dim + , subq_3.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -331,8 +331,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_8 - ) subq_9 + ) subq_3 + ) subq_4 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -375,86 +375,86 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_11.ds_partitioned__day - , subq_11.ds_partitioned__week - , subq_11.ds_partitioned__month - , subq_11.ds_partitioned__quarter - , subq_11.ds_partitioned__year - , subq_11.ds_partitioned__extract_year - , subq_11.ds_partitioned__extract_quarter - , subq_11.ds_partitioned__extract_month - , subq_11.ds_partitioned__extract_day - , subq_11.ds_partitioned__extract_dow - , subq_11.ds_partitioned__extract_doy - , subq_11.customer_id__ds_partitioned__day - , subq_11.customer_id__ds_partitioned__week - , subq_11.customer_id__ds_partitioned__month - , subq_11.customer_id__ds_partitioned__quarter - , subq_11.customer_id__ds_partitioned__year - , subq_11.customer_id__ds_partitioned__extract_year - , subq_11.customer_id__ds_partitioned__extract_quarter - , subq_11.customer_id__ds_partitioned__extract_month - , subq_11.customer_id__ds_partitioned__extract_day - , subq_11.customer_id__ds_partitioned__extract_dow - , subq_11.customer_id__ds_partitioned__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.customer_id - , subq_11.customer_name - , subq_11.customer_atomic_weight - , subq_11.customer_id__customer_name - , subq_11.customer_id__customer_atomic_weight + 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.customer_id__ds_partitioned__day + , subq_6.customer_id__ds_partitioned__week + , subq_6.customer_id__ds_partitioned__month + , subq_6.customer_id__ds_partitioned__quarter + , subq_6.customer_id__ds_partitioned__year + , subq_6.customer_id__ds_partitioned__extract_year + , subq_6.customer_id__ds_partitioned__extract_quarter + , subq_6.customer_id__ds_partitioned__extract_month + , subq_6.customer_id__ds_partitioned__extract_day + , subq_6.customer_id__ds_partitioned__extract_dow + , subq_6.customer_id__ds_partitioned__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.customer_id + , subq_6.customer_name + , subq_6.customer_atomic_weight + , subq_6.customer_id__customer_name + , subq_6.customer_id__customer_atomic_weight FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - 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.customer_id__ds_partitioned__day - , subq_10.customer_id__ds_partitioned__week - , subq_10.customer_id__ds_partitioned__month - , subq_10.customer_id__ds_partitioned__quarter - , subq_10.customer_id__ds_partitioned__year - , subq_10.customer_id__ds_partitioned__extract_year - , subq_10.customer_id__ds_partitioned__extract_quarter - , subq_10.customer_id__ds_partitioned__extract_month - , subq_10.customer_id__ds_partitioned__extract_day - , subq_10.customer_id__ds_partitioned__extract_dow - , subq_10.customer_id__ds_partitioned__extract_doy - , subq_10.ds_partitioned__day AS metric_time__day - , subq_10.ds_partitioned__week AS metric_time__week - , subq_10.ds_partitioned__month AS metric_time__month - , subq_10.ds_partitioned__quarter AS metric_time__quarter - , subq_10.ds_partitioned__year AS metric_time__year - , subq_10.ds_partitioned__extract_year AS metric_time__extract_year - , subq_10.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_10.ds_partitioned__extract_month AS metric_time__extract_month - , subq_10.ds_partitioned__extract_day AS metric_time__extract_day - , subq_10.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_10.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_10.customer_id - , subq_10.customer_name - , subq_10.customer_atomic_weight - , subq_10.customer_id__customer_name - , subq_10.customer_id__customer_atomic_weight - , subq_10.customers + subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.customer_id__ds_partitioned__day + , subq_5.customer_id__ds_partitioned__week + , subq_5.customer_id__ds_partitioned__month + , subq_5.customer_id__ds_partitioned__quarter + , subq_5.customer_id__ds_partitioned__year + , subq_5.customer_id__ds_partitioned__extract_year + , subq_5.customer_id__ds_partitioned__extract_quarter + , subq_5.customer_id__ds_partitioned__extract_month + , subq_5.customer_id__ds_partitioned__extract_day + , subq_5.customer_id__ds_partitioned__extract_dow + , subq_5.customer_id__ds_partitioned__extract_doy + , subq_5.ds_partitioned__day AS metric_time__day + , subq_5.ds_partitioned__week AS metric_time__week + , subq_5.ds_partitioned__month AS metric_time__month + , subq_5.ds_partitioned__quarter AS metric_time__quarter + , subq_5.ds_partitioned__year AS metric_time__year + , subq_5.ds_partitioned__extract_year AS metric_time__extract_year + , subq_5.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_5.ds_partitioned__extract_month AS metric_time__extract_month + , subq_5.ds_partitioned__extract_day AS metric_time__extract_day + , subq_5.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_5.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_5.customer_id + , subq_5.customer_name + , subq_5.customer_atomic_weight + , subq_5.customer_id__customer_name + , subq_5.customer_id__customer_atomic_weight + , subq_5.customers FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT @@ -487,25 +487,25 @@ FROM ( , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy , customer_table_src_22000.customer_id FROM ***************************.customer_table customer_table_src_22000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_5 + ) subq_6 + ) subq_7 ON ( - subq_9.customer_id = subq_12.customer_id + subq_4.customer_id = subq_7.customer_id ) AND ( - subq_9.ds_partitioned__day = subq_12.ds_partitioned__day + subq_4.ds_partitioned__day = subq_7.ds_partitioned__day ) - ) subq_13 - ) subq_14 + ) subq_8 + ) subq_9 ON ( - subq_7.account_id = subq_14.account_id + subq_2.account_id = subq_9.account_id ) AND ( - subq_7.ds_partitioned__day = subq_14.ds_partitioned__day + subq_2.ds_partitioned__day = subq_9.ds_partitioned__day ) - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 GROUP BY - subq_16.account_id__customer_id__customer_name -) subq_17 + subq_11.account_id__customer_id__customer_name +) subq_12 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0_optimized.sql index ba4d2593ef..13473156ca 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_32.customer_id__customer_name AS account_id__customer_id__customer_name + subq_22.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -22,12 +22,12 @@ LEFT OUTER JOIN ( ) AND ( DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) ) -) subq_32 +) subq_22 ON ( - account_month_txns_src_22000.account_id = subq_32.account_id + account_month_txns_src_22000.account_id = subq_22.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_32.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_22.ds_partitioned__day ) GROUP BY - subq_32.customer_id__customer_name + subq_22.customer_id__customer_name diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0.sql index 249f2823e8..7b77ae03e2 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0.sql @@ -1,221 +1,221 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_9.bookings) AS bookings - , MAX(subq_15.listings) AS listings + MAX(subq_5.bookings) AS bookings + , MAX(subq_11.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_8.bookings + subq_4.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_7.bookings) AS bookings + SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_6.bookings + subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.ds__day - , subq_5.ds__week - , subq_5.ds__month - , subq_5.ds__quarter - , subq_5.ds__year - , subq_5.ds__extract_year - , subq_5.ds__extract_quarter - , subq_5.ds__extract_month - , subq_5.ds__extract_day - , subq_5.ds__extract_dow - , subq_5.ds__extract_doy - , subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.paid_at__day - , subq_5.paid_at__week - , subq_5.paid_at__month - , subq_5.paid_at__quarter - , subq_5.paid_at__year - , subq_5.paid_at__extract_year - , subq_5.paid_at__extract_quarter - , subq_5.paid_at__extract_month - , subq_5.paid_at__extract_day - , subq_5.paid_at__extract_dow - , subq_5.paid_at__extract_doy - , subq_5.booking__ds__day - , subq_5.booking__ds__week - , subq_5.booking__ds__month - , subq_5.booking__ds__quarter - , subq_5.booking__ds__year - , subq_5.booking__ds__extract_year - , subq_5.booking__ds__extract_quarter - , subq_5.booking__ds__extract_month - , subq_5.booking__ds__extract_day - , subq_5.booking__ds__extract_dow - , subq_5.booking__ds__extract_doy - , subq_5.booking__ds_partitioned__day - , subq_5.booking__ds_partitioned__week - , subq_5.booking__ds_partitioned__month - , subq_5.booking__ds_partitioned__quarter - , subq_5.booking__ds_partitioned__year - , subq_5.booking__ds_partitioned__extract_year - , subq_5.booking__ds_partitioned__extract_quarter - , subq_5.booking__ds_partitioned__extract_month - , subq_5.booking__ds_partitioned__extract_day - , subq_5.booking__ds_partitioned__extract_dow - , subq_5.booking__ds_partitioned__extract_doy - , subq_5.booking__paid_at__day - , subq_5.booking__paid_at__week - , subq_5.booking__paid_at__month - , subq_5.booking__paid_at__quarter - , subq_5.booking__paid_at__year - , subq_5.booking__paid_at__extract_year - , subq_5.booking__paid_at__extract_quarter - , subq_5.booking__paid_at__extract_month - , subq_5.booking__paid_at__extract_day - , subq_5.booking__paid_at__extract_dow - , subq_5.booking__paid_at__extract_doy - , subq_5.metric_time__day - , subq_5.metric_time__week - , subq_5.metric_time__month - , subq_5.metric_time__quarter - , subq_5.metric_time__year - , subq_5.metric_time__extract_year - , subq_5.metric_time__extract_quarter - , subq_5.metric_time__extract_month - , subq_5.metric_time__extract_day - , subq_5.metric_time__extract_dow - , subq_5.metric_time__extract_doy - , subq_5.listing - , subq_5.guest - , subq_5.host - , subq_5.booking__listing - , subq_5.booking__guest - , subq_5.booking__host - , subq_5.is_instant - , subq_5.booking__is_instant - , subq_5.bookings - , subq_5.instant_bookings - , subq_5.booking_value - , subq_5.max_booking_value - , subq_5.min_booking_value - , subq_5.bookers - , subq_5.average_booking_value - , subq_5.referred_bookings - , subq_5.median_booking_value - , subq_5.booking_value_p99 - , subq_5.discrete_booking_value_p99 - , subq_5.approximate_continuous_booking_value_p99 - , subq_5.approximate_discrete_booking_value_p99 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.ds__week - , subq_4.ds__month - , subq_4.ds__quarter - , subq_4.ds__year - , subq_4.ds__extract_year - , subq_4.ds__extract_quarter - , subq_4.ds__extract_month - , subq_4.ds__extract_day - , subq_4.ds__extract_dow - , subq_4.ds__extract_doy - , subq_4.ds_partitioned__day - , subq_4.ds_partitioned__week - , subq_4.ds_partitioned__month - , subq_4.ds_partitioned__quarter - , subq_4.ds_partitioned__year - , subq_4.ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy - , subq_4.paid_at__day - , subq_4.paid_at__week - , subq_4.paid_at__month - , subq_4.paid_at__quarter - , subq_4.paid_at__year - , subq_4.paid_at__extract_year - , subq_4.paid_at__extract_quarter - , subq_4.paid_at__extract_month - , subq_4.paid_at__extract_day - , subq_4.paid_at__extract_dow - , subq_4.paid_at__extract_doy - , subq_4.booking__ds__day - , subq_4.booking__ds__week - , subq_4.booking__ds__month - , subq_4.booking__ds__quarter - , subq_4.booking__ds__year - , subq_4.booking__ds__extract_year - , subq_4.booking__ds__extract_quarter - , subq_4.booking__ds__extract_month - , subq_4.booking__ds__extract_day - , subq_4.booking__ds__extract_dow - , subq_4.booking__ds__extract_doy - , subq_4.booking__ds_partitioned__day - , subq_4.booking__ds_partitioned__week - , subq_4.booking__ds_partitioned__month - , subq_4.booking__ds_partitioned__quarter - , subq_4.booking__ds_partitioned__year - , subq_4.booking__ds_partitioned__extract_year - , subq_4.booking__ds_partitioned__extract_quarter - , subq_4.booking__ds_partitioned__extract_month - , subq_4.booking__ds_partitioned__extract_day - , subq_4.booking__ds_partitioned__extract_dow - , subq_4.booking__ds_partitioned__extract_doy - , subq_4.booking__paid_at__day - , subq_4.booking__paid_at__week - , subq_4.booking__paid_at__month - , subq_4.booking__paid_at__quarter - , subq_4.booking__paid_at__year - , subq_4.booking__paid_at__extract_year - , subq_4.booking__paid_at__extract_quarter - , subq_4.booking__paid_at__extract_month - , subq_4.booking__paid_at__extract_day - , subq_4.booking__paid_at__extract_dow - , subq_4.booking__paid_at__extract_doy - , subq_4.ds__day AS metric_time__day - , subq_4.ds__week AS metric_time__week - , subq_4.ds__month AS metric_time__month - , subq_4.ds__quarter AS metric_time__quarter - , subq_4.ds__year AS metric_time__year - , subq_4.ds__extract_year AS metric_time__extract_year - , subq_4.ds__extract_quarter AS metric_time__extract_quarter - , subq_4.ds__extract_month AS metric_time__extract_month - , subq_4.ds__extract_day AS metric_time__extract_day - , subq_4.ds__extract_dow AS metric_time__extract_dow - , subq_4.ds__extract_doy AS metric_time__extract_doy - , subq_4.listing - , subq_4.guest - , subq_4.host - , subq_4.booking__listing - , subq_4.booking__guest - , subq_4.booking__host - , subq_4.is_instant - , subq_4.booking__is_instant - , subq_4.bookings - , subq_4.instant_bookings - , subq_4.booking_value - , subq_4.max_booking_value - , subq_4.min_booking_value - , subq_4.bookers - , subq_4.average_booking_value - , subq_4.referred_bookings - , subq_4.median_booking_value - , subq_4.booking_value_p99 - , subq_4.discrete_booking_value_p99 - , subq_4.approximate_continuous_booking_value_p99 - , subq_4.approximate_discrete_booking_value_p99 + 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 @@ -308,165 +308,165 @@ 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_4 - ) subq_5 - WHERE subq_5.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' - ) subq_6 - ) subq_7 - ) subq_8 -) subq_9 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + ) subq_2 + ) subq_3 + ) subq_4 +) subq_5 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_14.listings + subq_10.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_13.listings) AS listings + SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_12.listings + subq_8.listings FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.created_at__day - , subq_11.created_at__week - , subq_11.created_at__month - , subq_11.created_at__quarter - , subq_11.created_at__year - , subq_11.created_at__extract_year - , subq_11.created_at__extract_quarter - , subq_11.created_at__extract_month - , subq_11.created_at__extract_day - , subq_11.created_at__extract_dow - , subq_11.created_at__extract_doy - , subq_11.listing__ds__day - , subq_11.listing__ds__week - , subq_11.listing__ds__month - , subq_11.listing__ds__quarter - , subq_11.listing__ds__year - , subq_11.listing__ds__extract_year - , subq_11.listing__ds__extract_quarter - , subq_11.listing__ds__extract_month - , subq_11.listing__ds__extract_day - , subq_11.listing__ds__extract_dow - , subq_11.listing__ds__extract_doy - , subq_11.listing__created_at__day - , subq_11.listing__created_at__week - , subq_11.listing__created_at__month - , subq_11.listing__created_at__quarter - , subq_11.listing__created_at__year - , subq_11.listing__created_at__extract_year - , subq_11.listing__created_at__extract_quarter - , subq_11.listing__created_at__extract_month - , subq_11.listing__created_at__extract_day - , subq_11.listing__created_at__extract_dow - , subq_11.listing__created_at__extract_doy - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.listing - , subq_11.user - , subq_11.listing__user - , subq_11.country_latest - , subq_11.is_lux_latest - , subq_11.capacity_latest - , subq_11.listing__country_latest - , subq_11.listing__is_lux_latest - , subq_11.listing__capacity_latest - , subq_11.listings - , subq_11.largest_listing - , subq_11.smallest_listing + 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.created_at__day + , subq_7.created_at__week + , subq_7.created_at__month + , subq_7.created_at__quarter + , subq_7.created_at__year + , subq_7.created_at__extract_year + , subq_7.created_at__extract_quarter + , subq_7.created_at__extract_month + , subq_7.created_at__extract_day + , subq_7.created_at__extract_dow + , subq_7.created_at__extract_doy + , subq_7.listing__ds__day + , subq_7.listing__ds__week + , subq_7.listing__ds__month + , subq_7.listing__ds__quarter + , subq_7.listing__ds__year + , subq_7.listing__ds__extract_year + , subq_7.listing__ds__extract_quarter + , subq_7.listing__ds__extract_month + , subq_7.listing__ds__extract_day + , subq_7.listing__ds__extract_dow + , subq_7.listing__ds__extract_doy + , subq_7.listing__created_at__day + , subq_7.listing__created_at__week + , subq_7.listing__created_at__month + , subq_7.listing__created_at__quarter + , subq_7.listing__created_at__year + , subq_7.listing__created_at__extract_year + , subq_7.listing__created_at__extract_quarter + , subq_7.listing__created_at__extract_month + , subq_7.listing__created_at__extract_day + , subq_7.listing__created_at__extract_dow + , subq_7.listing__created_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.user + , subq_7.listing__user + , subq_7.country_latest + , subq_7.is_lux_latest + , subq_7.capacity_latest + , subq_7.listing__country_latest + , subq_7.listing__is_lux_latest + , subq_7.listing__capacity_latest + , subq_7.listings + , subq_7.largest_listing + , subq_7.smallest_listing 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 @@ -527,10 +527,10 @@ CROSS JOIN ( , 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 - WHERE subq_11.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' - ) subq_12 - ) subq_13 - ) subq_14 -) subq_15 + ) subq_6 + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + ) subq_8 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0_optimized.sql index c2ae87e51d..e393d122a8 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs SELECT - MAX(subq_25.bookings) AS bookings - , MAX(subq_31.listings) AS listings + MAX(subq_17.bookings) AS bookings + , MAX(subq_23.listings) AS listings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -13,7 +13,7 @@ FROM ( SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' -) subq_25 +) subq_17 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' @@ -25,4 +25,4 @@ CROSS JOIN ( SUM(1) AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 WHERE DATE_TRUNC('day', created_at) BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' -) subq_31 +) subq_23 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index f87c77add1..6dd6280953 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -1,236 +1,236 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 + subq_8.metric_time__day + , COALESCE(subq_8.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_7.metric_time__day + , subq_7.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - WHERE subq_8.ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_7 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + WHERE subq_6.ds BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -323,16 +323,16 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 + ) subq_3 GROUP BY metric_time__day - ) subq_6 + ) subq_4 ON - subq_7.metric_time__day = subq_6.metric_time__day - ) subq_9 - WHERE subq_9.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_10 + subq_5.metric_time__day = subq_4.metric_time__day + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_8 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql index 4ad0535693..b0ed4836c9 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql @@ -6,15 +6,15 @@ FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_18.metric_time__day AS metric_time__day - , subq_17.bookings AS bookings + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_19 + FROM ***************************.mf_time_spine subq_15 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_18 + ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -30,11 +30,11 @@ FROM ( , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATETIME_TRUNC(ds, day) BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_16 + ) subq_12 GROUP BY metric_time__day - ) subq_17 + ) subq_13 ON - subq_18.metric_time__day = subq_17.metric_time__day - WHERE subq_18.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_21 + subq_14.metric_time__day = subq_13.metric_time__day + WHERE subq_14.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_time_constraint__plan0.sql index 142fcaa898..b34ef3be92 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_time_constraint__plan0.sql @@ -1,216 +1,216 @@ -- Compute Metrics via Expressions SELECT - COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + COALESCE(subq_4.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - SUM(subq_5.bookings) AS bookings + SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_4.bookings + subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -303,9 +303,9 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_4 - ) subq_5 -) subq_6 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 + ) subq_3 +) subq_4 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql index a51167b209..f7c49d0fd2 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql @@ -11,4 +11,4 @@ FROM ( SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATETIME_TRUNC(ds, day) BETWEEN '2020-01-03' AND '2020-01-05' -) subq_13 +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0.sql index 077d44257f..a953b343b8 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_9.metric_time__day + , COALESCE(subq_9.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings AS bookings + subq_7.metric_time__day AS metric_time__day + , subq_6.bookings AS bookings FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_8.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_8 + ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_5.metric_time__day + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_4.metric_time__day + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -329,17 +329,17 @@ 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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY metric_time__day - ) subq_8 + ) subq_6 ON - subq_9.metric_time__day = subq_8.metric_time__day -) subq_11 + subq_7.metric_time__day = subq_6.metric_time__day +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 55193d5428..b17417bb44 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + subq_18.ds AS metric_time__day + , subq_16.bookings AS bookings + FROM ***************************.mf_time_spine subq_18 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,13 +30,13 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_11 WHERE booking__is_instant - ) subq_17 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_20 + ) subq_16 ON - subq_22.ds = subq_20.metric_time__day -) subq_23 + subq_18.ds = subq_16.metric_time__day +) subq_19 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index 97202fe9e5..99a06ee89d 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -1,246 +1,246 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.booking__is_instant - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_9.metric_time__day + , subq_9.booking__is_instant + , COALESCE(subq_9.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.booking__is_instant - , subq_10.bookings + subq_8.metric_time__day + , subq_8.booking__is_instant + , subq_8.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.booking__is_instant AS booking__is_instant - , subq_7.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.booking__is_instant AS booking__is_instant + , subq_5.bookings AS bookings FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - ) subq_8 + subq_7.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_7 + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , SUM(subq_6.bookings) AS bookings + subq_4.metric_time__day + , subq_4.booking__is_instant + , SUM(subq_4.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -333,19 +333,19 @@ 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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 + ) subq_4 GROUP BY metric_time__day , booking__is_instant - ) subq_7 + ) subq_5 ON - subq_8.metric_time__day = subq_7.metric_time__day - ) subq_10 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_8 WHERE booking__is_instant -) subq_11 +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 99937b7b72..2ab9b8920c 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -12,10 +12,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_21.ds AS metric_time__day - , subq_19.booking__is_instant AS booking__is_instant - , subq_19.bookings AS bookings - FROM ***************************.mf_time_spine subq_21 + subq_17.ds AS metric_time__day + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + FROM ***************************.mf_time_spine subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -38,16 +38,16 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_11 WHERE booking__is_instant - ) subq_17 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day , booking__is_instant - ) subq_19 + ) subq_15 ON - subq_21.ds = subq_19.metric_time__day - ) subq_22 + subq_17.ds = subq_15.metric_time__day + ) subq_18 WHERE booking__is_instant -) subq_23 +) subq_19 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index eac280b629..971ce1cff6 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -1,236 +1,236 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 + subq_8.metric_time__day + , COALESCE(subq_8.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_7.metric_time__day + , subq_7.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - WHERE subq_8.ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_7 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + WHERE subq_6.ds BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -323,16 +323,16 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 + ) subq_3 GROUP BY - subq_5.metric_time__day - ) subq_6 + subq_3.metric_time__day + ) subq_4 ON - subq_7.metric_time__day = subq_6.metric_time__day - ) subq_9 - WHERE subq_9.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_10 + subq_5.metric_time__day = subq_4.metric_time__day + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_8 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql index 6b034b9ed6..fb7e2c593f 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql @@ -6,15 +6,15 @@ FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_18.metric_time__day AS metric_time__day - , subq_17.bookings AS bookings + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_19 + FROM ***************************.mf_time_spine subq_15 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_18 + ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -30,11 +30,11 @@ FROM ( , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_16 + ) subq_12 GROUP BY metric_time__day - ) subq_17 + ) subq_13 ON - subq_18.metric_time__day = subq_17.metric_time__day - WHERE subq_18.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_21 + subq_14.metric_time__day = subq_13.metric_time__day + WHERE subq_14.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_time_constraint__plan0.sql index 0ea5d2e977..629d3ebc69 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_time_constraint__plan0.sql @@ -1,216 +1,216 @@ -- Compute Metrics via Expressions SELECT - COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + COALESCE(subq_4.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - SUM(subq_5.bookings) AS bookings + SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_4.bookings + subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -303,9 +303,9 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_4 - ) subq_5 -) subq_6 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 + ) subq_3 +) subq_4 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql index 1e168751c0..f4298198ec 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql @@ -11,4 +11,4 @@ FROM ( SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-03' AND '2020-01-05' -) subq_13 +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0.sql index c6a4a763f6..d60ece757b 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_9.metric_time__day + , COALESCE(subq_9.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings AS bookings + subq_7.metric_time__day AS metric_time__day + , subq_6.bookings AS bookings FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_8.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_8 + ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_5.metric_time__day + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_4.metric_time__day + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -329,17 +329,17 @@ 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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 + subq_5.metric_time__day + ) subq_6 ON - subq_9.metric_time__day = subq_8.metric_time__day -) subq_11 + subq_7.metric_time__day = subq_6.metric_time__day +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 171a4ddc33..1651c30848 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + subq_18.ds AS metric_time__day + , subq_16.bookings AS bookings + FROM ***************************.mf_time_spine subq_18 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,13 +30,13 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_11 WHERE booking__is_instant - ) subq_17 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_20 + ) subq_16 ON - subq_22.ds = subq_20.metric_time__day -) subq_23 + subq_18.ds = subq_16.metric_time__day +) subq_19 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index 5d08b97f19..8b503a6ff1 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -1,246 +1,246 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.booking__is_instant - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_9.metric_time__day + , subq_9.booking__is_instant + , COALESCE(subq_9.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.booking__is_instant - , subq_10.bookings + subq_8.metric_time__day + , subq_8.booking__is_instant + , subq_8.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.booking__is_instant AS booking__is_instant - , subq_7.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.booking__is_instant AS booking__is_instant + , subq_5.bookings AS bookings FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - ) subq_8 + subq_7.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_7 + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , SUM(subq_6.bookings) AS bookings + subq_4.metric_time__day + , subq_4.booking__is_instant + , SUM(subq_4.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -333,19 +333,19 @@ 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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 + ) subq_4 GROUP BY - subq_6.metric_time__day - , subq_6.booking__is_instant - ) subq_7 + subq_4.metric_time__day + , subq_4.booking__is_instant + ) subq_5 ON - subq_8.metric_time__day = subq_7.metric_time__day - ) subq_10 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_8 WHERE booking__is_instant -) subq_11 +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 51af44d6c4..c2865a7e58 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -12,10 +12,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_21.ds AS metric_time__day - , subq_19.booking__is_instant AS booking__is_instant - , subq_19.bookings AS bookings - FROM ***************************.mf_time_spine subq_21 + subq_17.ds AS metric_time__day + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + FROM ***************************.mf_time_spine subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -38,16 +38,16 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_11 WHERE booking__is_instant - ) subq_17 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day , booking__is_instant - ) subq_19 + ) subq_15 ON - subq_21.ds = subq_19.metric_time__day - ) subq_22 + subq_17.ds = subq_15.metric_time__day + ) subq_18 WHERE booking__is_instant -) subq_23 +) subq_19 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index bea9a8e3f5..a7fd42dafc 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -1,236 +1,236 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 + subq_8.metric_time__day + , COALESCE(subq_8.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_7.metric_time__day + , subq_7.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - WHERE subq_8.ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_7 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + WHERE subq_6.ds BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -323,16 +323,16 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 + ) subq_3 GROUP BY - subq_5.metric_time__day - ) subq_6 + subq_3.metric_time__day + ) subq_4 ON - subq_7.metric_time__day = subq_6.metric_time__day - ) subq_9 - WHERE subq_9.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_10 + subq_5.metric_time__day = subq_4.metric_time__day + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_8 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql index 6b034b9ed6..fb7e2c593f 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql @@ -6,15 +6,15 @@ FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_18.metric_time__day AS metric_time__day - , subq_17.bookings AS bookings + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_19 + FROM ***************************.mf_time_spine subq_15 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_18 + ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -30,11 +30,11 @@ FROM ( , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_16 + ) subq_12 GROUP BY metric_time__day - ) subq_17 + ) subq_13 ON - subq_18.metric_time__day = subq_17.metric_time__day - WHERE subq_18.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_21 + subq_14.metric_time__day = subq_13.metric_time__day + WHERE subq_14.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_time_constraint__plan0.sql index 78636ba2d8..ae43a32c06 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_time_constraint__plan0.sql @@ -1,216 +1,216 @@ -- Compute Metrics via Expressions SELECT - COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + COALESCE(subq_4.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - SUM(subq_5.bookings) AS bookings + SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_4.bookings + subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -303,9 +303,9 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_4 - ) subq_5 -) subq_6 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 + ) subq_3 +) subq_4 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql index 1e168751c0..f4298198ec 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql @@ -11,4 +11,4 @@ FROM ( SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-03' AND '2020-01-05' -) subq_13 +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0.sql index 077b8a4c94..d54e30d707 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_9.metric_time__day + , COALESCE(subq_9.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings AS bookings + subq_7.metric_time__day AS metric_time__day + , subq_6.bookings AS bookings FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_8.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_8 + ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_5.metric_time__day + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_4.metric_time__day + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -329,17 +329,17 @@ 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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 + subq_5.metric_time__day + ) subq_6 ON - subq_9.metric_time__day = subq_8.metric_time__day -) subq_11 + subq_7.metric_time__day = subq_6.metric_time__day +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 171a4ddc33..1651c30848 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + subq_18.ds AS metric_time__day + , subq_16.bookings AS bookings + FROM ***************************.mf_time_spine subq_18 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,13 +30,13 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_11 WHERE booking__is_instant - ) subq_17 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_20 + ) subq_16 ON - subq_22.ds = subq_20.metric_time__day -) subq_23 + subq_18.ds = subq_16.metric_time__day +) subq_19 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index fe5d8ea8c7..79ef200851 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -1,246 +1,246 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.booking__is_instant - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_9.metric_time__day + , subq_9.booking__is_instant + , COALESCE(subq_9.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.booking__is_instant - , subq_10.bookings + subq_8.metric_time__day + , subq_8.booking__is_instant + , subq_8.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.booking__is_instant AS booking__is_instant - , subq_7.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.booking__is_instant AS booking__is_instant + , subq_5.bookings AS bookings FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - ) subq_8 + subq_7.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_7 + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , SUM(subq_6.bookings) AS bookings + subq_4.metric_time__day + , subq_4.booking__is_instant + , SUM(subq_4.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -333,19 +333,19 @@ 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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 + ) subq_4 GROUP BY - subq_6.metric_time__day - , subq_6.booking__is_instant - ) subq_7 + subq_4.metric_time__day + , subq_4.booking__is_instant + ) subq_5 ON - subq_8.metric_time__day = subq_7.metric_time__day - ) subq_10 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_8 WHERE booking__is_instant -) subq_11 +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 51af44d6c4..c2865a7e58 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -12,10 +12,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_21.ds AS metric_time__day - , subq_19.booking__is_instant AS booking__is_instant - , subq_19.bookings AS bookings - FROM ***************************.mf_time_spine subq_21 + subq_17.ds AS metric_time__day + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + FROM ***************************.mf_time_spine subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -38,16 +38,16 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_11 WHERE booking__is_instant - ) subq_17 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day , booking__is_instant - ) subq_19 + ) subq_15 ON - subq_21.ds = subq_19.metric_time__day - ) subq_22 + subq_17.ds = subq_15.metric_time__day + ) subq_18 WHERE booking__is_instant -) subq_23 +) subq_19 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index 3dbf843434..0e3b950240 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -1,236 +1,236 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 + subq_8.metric_time__day + , COALESCE(subq_8.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_7.metric_time__day + , subq_7.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - WHERE subq_8.ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_7 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + WHERE subq_6.ds BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -323,16 +323,16 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 + ) subq_3 GROUP BY - subq_5.metric_time__day - ) subq_6 + subq_3.metric_time__day + ) subq_4 ON - subq_7.metric_time__day = subq_6.metric_time__day - ) subq_9 - WHERE subq_9.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_10 + subq_5.metric_time__day = subq_4.metric_time__day + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_8 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql index 6b034b9ed6..fb7e2c593f 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql @@ -6,15 +6,15 @@ FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_18.metric_time__day AS metric_time__day - , subq_17.bookings AS bookings + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_19 + FROM ***************************.mf_time_spine subq_15 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_18 + ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -30,11 +30,11 @@ FROM ( , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_16 + ) subq_12 GROUP BY metric_time__day - ) subq_17 + ) subq_13 ON - subq_18.metric_time__day = subq_17.metric_time__day - WHERE subq_18.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_21 + subq_14.metric_time__day = subq_13.metric_time__day + WHERE subq_14.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_time_constraint__plan0.sql index d6a4c41227..18d24a1dcb 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_time_constraint__plan0.sql @@ -1,216 +1,216 @@ -- Compute Metrics via Expressions SELECT - COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + COALESCE(subq_4.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - SUM(subq_5.bookings) AS bookings + SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_4.bookings + subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -303,9 +303,9 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_4 - ) subq_5 -) subq_6 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 + ) subq_3 +) subq_4 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql index 1e168751c0..f4298198ec 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql @@ -11,4 +11,4 @@ FROM ( SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-03' AND '2020-01-05' -) subq_13 +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0.sql index 98806a7229..c37f9ef8f3 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_9.metric_time__day + , COALESCE(subq_9.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings AS bookings + subq_7.metric_time__day AS metric_time__day + , subq_6.bookings AS bookings FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_8.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_8 + ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_5.metric_time__day + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_4.metric_time__day + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -329,17 +329,17 @@ 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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 + subq_5.metric_time__day + ) subq_6 ON - subq_9.metric_time__day = subq_8.metric_time__day -) subq_11 + subq_7.metric_time__day = subq_6.metric_time__day +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 171a4ddc33..1651c30848 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + subq_18.ds AS metric_time__day + , subq_16.bookings AS bookings + FROM ***************************.mf_time_spine subq_18 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,13 +30,13 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_11 WHERE booking__is_instant - ) subq_17 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_20 + ) subq_16 ON - subq_22.ds = subq_20.metric_time__day -) subq_23 + subq_18.ds = subq_16.metric_time__day +) subq_19 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index f88ef62297..6daf3e8b42 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -1,246 +1,246 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.booking__is_instant - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_9.metric_time__day + , subq_9.booking__is_instant + , COALESCE(subq_9.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.booking__is_instant - , subq_10.bookings + subq_8.metric_time__day + , subq_8.booking__is_instant + , subq_8.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.booking__is_instant AS booking__is_instant - , subq_7.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.booking__is_instant AS booking__is_instant + , subq_5.bookings AS bookings FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - ) subq_8 + subq_7.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_7 + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , SUM(subq_6.bookings) AS bookings + subq_4.metric_time__day + , subq_4.booking__is_instant + , SUM(subq_4.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -333,19 +333,19 @@ 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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 + ) subq_4 GROUP BY - subq_6.metric_time__day - , subq_6.booking__is_instant - ) subq_7 + subq_4.metric_time__day + , subq_4.booking__is_instant + ) subq_5 ON - subq_8.metric_time__day = subq_7.metric_time__day - ) subq_10 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_8 WHERE booking__is_instant -) subq_11 +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 51af44d6c4..c2865a7e58 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -12,10 +12,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_21.ds AS metric_time__day - , subq_19.booking__is_instant AS booking__is_instant - , subq_19.bookings AS bookings - FROM ***************************.mf_time_spine subq_21 + subq_17.ds AS metric_time__day + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + FROM ***************************.mf_time_spine subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -38,16 +38,16 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_11 WHERE booking__is_instant - ) subq_17 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day , booking__is_instant - ) subq_19 + ) subq_15 ON - subq_21.ds = subq_19.metric_time__day - ) subq_22 + subq_17.ds = subq_15.metric_time__day + ) subq_18 WHERE booking__is_instant -) subq_23 +) subq_19 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index 7212dccdb5..fd9ed3dd3b 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -1,236 +1,236 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 + subq_8.metric_time__day + , COALESCE(subq_8.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_7.metric_time__day + , subq_7.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - WHERE subq_8.ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_7 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + WHERE subq_6.ds BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -323,16 +323,16 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 + ) subq_3 GROUP BY - subq_5.metric_time__day - ) subq_6 + subq_3.metric_time__day + ) subq_4 ON - subq_7.metric_time__day = subq_6.metric_time__day - ) subq_9 - WHERE subq_9.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_10 + subq_5.metric_time__day = subq_4.metric_time__day + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_8 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql index 6b034b9ed6..fb7e2c593f 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql @@ -6,15 +6,15 @@ FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_18.metric_time__day AS metric_time__day - , subq_17.bookings AS bookings + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_19 + FROM ***************************.mf_time_spine subq_15 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_18 + ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -30,11 +30,11 @@ FROM ( , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_16 + ) subq_12 GROUP BY metric_time__day - ) subq_17 + ) subq_13 ON - subq_18.metric_time__day = subq_17.metric_time__day - WHERE subq_18.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_21 + subq_14.metric_time__day = subq_13.metric_time__day + WHERE subq_14.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_time_constraint__plan0.sql index 4bdb8514dc..57eeeab2ca 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_time_constraint__plan0.sql @@ -1,216 +1,216 @@ -- Compute Metrics via Expressions SELECT - COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + COALESCE(subq_4.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - SUM(subq_5.bookings) AS bookings + SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_4.bookings + subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -303,9 +303,9 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_4 - ) subq_5 -) subq_6 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 + ) subq_3 +) subq_4 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql index 1e168751c0..f4298198ec 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql @@ -11,4 +11,4 @@ FROM ( SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-03' AND '2020-01-05' -) subq_13 +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0.sql index 4faadd5042..ef36b4636d 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_9.metric_time__day + , COALESCE(subq_9.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings AS bookings + subq_7.metric_time__day AS metric_time__day + , subq_6.bookings AS bookings FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_8.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_8 + ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_5.metric_time__day + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_4.metric_time__day + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -329,17 +329,17 @@ 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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 + subq_5.metric_time__day + ) subq_6 ON - subq_9.metric_time__day = subq_8.metric_time__day -) subq_11 + subq_7.metric_time__day = subq_6.metric_time__day +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 171a4ddc33..1651c30848 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + subq_18.ds AS metric_time__day + , subq_16.bookings AS bookings + FROM ***************************.mf_time_spine subq_18 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,13 +30,13 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_11 WHERE booking__is_instant - ) subq_17 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_20 + ) subq_16 ON - subq_22.ds = subq_20.metric_time__day -) subq_23 + subq_18.ds = subq_16.metric_time__day +) subq_19 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index cd695ffcf8..1b9b967d8a 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -1,246 +1,246 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.booking__is_instant - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_9.metric_time__day + , subq_9.booking__is_instant + , COALESCE(subq_9.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.booking__is_instant - , subq_10.bookings + subq_8.metric_time__day + , subq_8.booking__is_instant + , subq_8.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.booking__is_instant AS booking__is_instant - , subq_7.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.booking__is_instant AS booking__is_instant + , subq_5.bookings AS bookings FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - ) subq_8 + subq_7.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_7 + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , SUM(subq_6.bookings) AS bookings + subq_4.metric_time__day + , subq_4.booking__is_instant + , SUM(subq_4.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -333,19 +333,19 @@ 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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 + ) subq_4 GROUP BY - subq_6.metric_time__day - , subq_6.booking__is_instant - ) subq_7 + subq_4.metric_time__day + , subq_4.booking__is_instant + ) subq_5 ON - subq_8.metric_time__day = subq_7.metric_time__day - ) subq_10 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_8 WHERE booking__is_instant -) subq_11 +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 51af44d6c4..c2865a7e58 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -12,10 +12,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_21.ds AS metric_time__day - , subq_19.booking__is_instant AS booking__is_instant - , subq_19.bookings AS bookings - FROM ***************************.mf_time_spine subq_21 + subq_17.ds AS metric_time__day + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + FROM ***************************.mf_time_spine subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -38,16 +38,16 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_11 WHERE booking__is_instant - ) subq_17 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day , booking__is_instant - ) subq_19 + ) subq_15 ON - subq_21.ds = subq_19.metric_time__day - ) subq_22 + subq_17.ds = subq_15.metric_time__day + ) subq_18 WHERE booking__is_instant -) subq_23 +) subq_19 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index 07eb5d6382..49f3c834a9 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -1,236 +1,236 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 + subq_8.metric_time__day + , COALESCE(subq_8.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_9.metric_time__day - , subq_9.bookings + subq_7.metric_time__day + , subq_7.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_8 - WHERE subq_8.ds BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' - ) subq_7 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + WHERE subq_6.ds BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -323,16 +323,16 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' - ) subq_4 - ) subq_5 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' + ) subq_2 + ) subq_3 GROUP BY - subq_5.metric_time__day - ) subq_6 + subq_3.metric_time__day + ) subq_4 ON - subq_7.metric_time__day = subq_6.metric_time__day - ) subq_9 - WHERE subq_9.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' -) subq_10 + subq_5.metric_time__day = subq_4.metric_time__day + ) subq_7 + WHERE subq_7.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' +) subq_8 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql index d51f6bdaf3..bfc306b207 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql @@ -6,15 +6,15 @@ FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_18.metric_time__day AS metric_time__day - , subq_17.bookings AS bookings + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_19 + FROM ***************************.mf_time_spine subq_15 WHERE ds BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' - ) subq_18 + ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -30,11 +30,11 @@ FROM ( , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' - ) subq_16 + ) subq_12 GROUP BY metric_time__day - ) subq_17 + ) subq_13 ON - subq_18.metric_time__day = subq_17.metric_time__day - WHERE subq_18.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' -) subq_21 + subq_14.metric_time__day = subq_13.metric_time__day + WHERE subq_14.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' +) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_time_constraint__plan0.sql index fac4575af2..ec7a55c001 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_time_constraint__plan0.sql @@ -1,216 +1,216 @@ -- Compute Metrics via Expressions SELECT - COALESCE(subq_6.bookings, 0) AS bookings_fill_nulls_with_0 + COALESCE(subq_4.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Aggregate Measures SELECT - SUM(subq_5.bookings) AS bookings + SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_4.bookings + subq_2.bookings FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -303,9 +303,9 @@ 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_2 - ) subq_3 - WHERE subq_3.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' - ) subq_4 - ) subq_5 -) subq_6 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' + ) subq_2 + ) subq_3 +) subq_4 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql index 69dc5ec31d..1d8ac5c597 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_time_constraint__plan0_optimized.sql @@ -11,4 +11,4 @@ FROM ( SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' -) subq_13 +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0.sql index 666b0545f3..73f8d23c53 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -1,242 +1,242 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_9.metric_time__day + , COALESCE(subq_9.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_9.metric_time__day AS metric_time__day - , subq_8.bookings AS bookings + subq_7.metric_time__day AS metric_time__day + , subq_6.bookings AS bookings FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_10 - ) subq_9 + subq_8.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_8 + ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_7.metric_time__day - , SUM(subq_7.bookings) AS bookings + subq_5.metric_time__day + , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_6.metric_time__day - , subq_6.bookings + subq_4.metric_time__day + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -329,17 +329,17 @@ 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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 GROUP BY - subq_7.metric_time__day - ) subq_8 + subq_5.metric_time__day + ) subq_6 ON - subq_9.metric_time__day = subq_8.metric_time__day -) subq_11 + subq_7.metric_time__day = subq_6.metric_time__day +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 171a4ddc33..1651c30848 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day - , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + subq_18.ds AS metric_time__day + , subq_16.bookings AS bookings + FROM ***************************.mf_time_spine subq_18 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,13 +30,13 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_11 WHERE booking__is_instant - ) subq_17 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_20 + ) subq_16 ON - subq_22.ds = subq_20.metric_time__day -) subq_23 + subq_18.ds = subq_16.metric_time__day +) subq_19 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index 224e31010d..8453c29d25 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -1,246 +1,246 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , subq_11.booking__is_instant - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_9.metric_time__day + , subq_9.booking__is_instant + , COALESCE(subq_9.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.booking__is_instant - , subq_10.bookings + subq_8.metric_time__day + , subq_8.booking__is_instant + , subq_8.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.booking__is_instant AS booking__is_instant - , subq_7.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.booking__is_instant AS booking__is_instant + , subq_5.bookings AS bookings FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_9 - ) subq_8 + subq_7.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_7 + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , SUM(subq_6.bookings) AS bookings + subq_4.metric_time__day + , subq_4.booking__is_instant + , SUM(subq_4.bookings) AS bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.booking__is_instant - , subq_5.bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , subq_3.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , subq_4.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings 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 + 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_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.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 + 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 @@ -333,19 +333,19 @@ 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_2 - ) subq_3 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_6 + ) subq_4 GROUP BY - subq_6.metric_time__day - , subq_6.booking__is_instant - ) subq_7 + subq_4.metric_time__day + , subq_4.booking__is_instant + ) subq_5 ON - subq_8.metric_time__day = subq_7.metric_time__day - ) subq_10 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_8 WHERE booking__is_instant -) subq_11 +) subq_9 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 51af44d6c4..c2865a7e58 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -12,10 +12,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_21.ds AS metric_time__day - , subq_19.booking__is_instant AS booking__is_instant - , subq_19.bookings AS bookings - FROM ***************************.mf_time_spine subq_21 + subq_17.ds AS metric_time__day + , subq_15.booking__is_instant AS booking__is_instant + , subq_15.bookings AS bookings + FROM ***************************.mf_time_spine subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Aggregate Measures @@ -38,16 +38,16 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_11 WHERE booking__is_instant - ) subq_17 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day , booking__is_instant - ) subq_19 + ) subq_15 ON - subq_21.ds = subq_19.metric_time__day - ) subq_22 + subq_17.ds = subq_15.metric_time__day + ) subq_18 WHERE booking__is_instant -) subq_23 +) subq_19