diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0.sql index e191074286..4da4d7d82c 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0.sql @@ -1,253 +1,192 @@ -- Pass Only Elements: ['user__home_state_latest',] SELECT - subq_7.user__home_state_latest + subq_4.user__home_state_latest FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.created_at__day + , subq_3.created_at__week + , subq_3.created_at__month + , subq_3.created_at__quarter + , subq_3.created_at__year + , subq_3.created_at__extract_year + , subq_3.created_at__extract_quarter + , subq_3.created_at__extract_month + , subq_3.created_at__extract_day + , subq_3.created_at__extract_dow + , subq_3.created_at__extract_doy + , subq_3.listing__ds__day + , subq_3.listing__ds__week + , subq_3.listing__ds__month + , subq_3.listing__ds__quarter + , subq_3.listing__ds__year + , subq_3.listing__ds__extract_year + , subq_3.listing__ds__extract_quarter + , subq_3.listing__ds__extract_month + , subq_3.listing__ds__extract_day + , subq_3.listing__ds__extract_dow + , subq_3.listing__ds__extract_doy + , subq_3.listing__created_at__day + , subq_3.listing__created_at__week + , subq_3.listing__created_at__month + , subq_3.listing__created_at__quarter + , subq_3.listing__created_at__year + , subq_3.listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month + , subq_3.listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy + , subq_3.listing + , subq_3.user + , subq_3.listing__user + , subq_3.country_latest + , subq_3.is_lux_latest + , subq_3.capacity_latest + , subq_3.listing__country_latest + , subq_3.listing__is_lux_latest + , subq_3.listing__capacity_latest + , subq_3.user__home_state_latest + , subq_3.listings + , subq_3.largest_listing + , subq_3.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_3.ds__day AS ds__day - , subq_3.ds__week AS ds__week - , subq_3.ds__month AS ds__month - , subq_3.ds__quarter AS ds__quarter - , subq_3.ds__year AS ds__year - , subq_3.ds__extract_year AS ds__extract_year - , subq_3.ds__extract_quarter AS ds__extract_quarter - , subq_3.ds__extract_month AS ds__extract_month - , subq_3.ds__extract_day AS ds__extract_day - , subq_3.ds__extract_dow AS ds__extract_dow - , subq_3.ds__extract_doy AS ds__extract_doy - , subq_3.created_at__day AS created_at__day - , subq_3.created_at__week AS created_at__week - , subq_3.created_at__month AS created_at__month - , subq_3.created_at__quarter AS created_at__quarter - , subq_3.created_at__year AS created_at__year - , subq_3.created_at__extract_year AS created_at__extract_year - , subq_3.created_at__extract_quarter AS created_at__extract_quarter - , subq_3.created_at__extract_month AS created_at__extract_month - , subq_3.created_at__extract_day AS created_at__extract_day - , subq_3.created_at__extract_dow AS created_at__extract_dow - , subq_3.created_at__extract_doy AS created_at__extract_doy - , subq_3.listing__ds__day AS listing__ds__day - , subq_3.listing__ds__week AS listing__ds__week - , subq_3.listing__ds__month AS listing__ds__month - , subq_3.listing__ds__quarter AS listing__ds__quarter - , subq_3.listing__ds__year AS listing__ds__year - , subq_3.listing__ds__extract_year AS listing__ds__extract_year - , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_3.listing__ds__extract_month AS listing__ds__extract_month - , subq_3.listing__ds__extract_day AS listing__ds__extract_day - , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_3.listing__created_at__day AS listing__created_at__day - , subq_3.listing__created_at__week AS listing__created_at__week - , subq_3.listing__created_at__month AS listing__created_at__month - , subq_3.listing__created_at__quarter AS listing__created_at__quarter - , subq_3.listing__created_at__year AS listing__created_at__year - , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_3.listing AS listing - , subq_3.user AS user - , subq_3.listing__user AS listing__user - , subq_3.country_latest AS country_latest - , subq_3.is_lux_latest AS is_lux_latest - , subq_3.capacity_latest AS capacity_latest - , subq_3.listing__country_latest AS listing__country_latest - , subq_3.listing__is_lux_latest AS listing__is_lux_latest - , subq_3.listing__capacity_latest AS listing__capacity_latest - , subq_5.home_state_latest AS user__home_state_latest - , subq_3.listings AS listings - , subq_3.largest_listing AS largest_listing - , subq_3.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_2.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_2.ds__day - , subq_2.ds__week - , subq_2.ds__month - , subq_2.ds__quarter - , subq_2.ds__year - , subq_2.ds__extract_year - , subq_2.ds__extract_quarter - , subq_2.ds__extract_month - , subq_2.ds__extract_day - , subq_2.ds__extract_dow - , subq_2.ds__extract_doy - , subq_2.created_at__day - , subq_2.created_at__week - , subq_2.created_at__month - , subq_2.created_at__quarter - , subq_2.created_at__year - , subq_2.created_at__extract_year - , subq_2.created_at__extract_quarter - , subq_2.created_at__extract_month - , subq_2.created_at__extract_day - , subq_2.created_at__extract_dow - , subq_2.created_at__extract_doy - , subq_2.listing__ds__day - , subq_2.listing__ds__week - , subq_2.listing__ds__month - , subq_2.listing__ds__quarter - , subq_2.listing__ds__year - , subq_2.listing__ds__extract_year - , subq_2.listing__ds__extract_quarter - , subq_2.listing__ds__extract_month - , subq_2.listing__ds__extract_day - , subq_2.listing__ds__extract_dow - , subq_2.listing__ds__extract_doy - , subq_2.listing__created_at__day - , subq_2.listing__created_at__week - , subq_2.listing__created_at__month - , subq_2.listing__created_at__quarter - , subq_2.listing__created_at__year - , subq_2.listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month - , subq_2.listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy - , subq_2.listing - , subq_2.user - , subq_2.listing__user - , subq_2.country_latest - , subq_2.is_lux_latest - , subq_2.capacity_latest - , subq_2.listing__country_latest - , subq_2.listing__is_lux_latest - , subq_2.listing__capacity_latest - , subq_2.listings - , subq_2.largest_listing - , subq_2.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 - WHERE listing__country_latest = 'us' - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_1.user + , subq_1.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -277,12 +216,12 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_4 - ) subq_5 + ) subq_1 + ) subq_2 ON - subq_3.user = subq_5.user - ) subq_6 + subq_0.user = subq_2.user + ) subq_3 WHERE listing__country_latest = 'us' -) subq_7 +) subq_4 GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0_optimized.sql index f2ac976dac..c4e57d3c86 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -5,27 +5,14 @@ SELECT FROM ( -- Join Standard Outputs SELECT - subq_9.listing__country_latest AS listing__country_latest + listings_latest_src_28000.country AS listing__country_latest , users_latest_src_28000.home_state_latest AS user__home_state_latest - FROM ( - -- Constrain Output with WHERE - SELECT - subq_8.user - , listing__country_latest - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - country AS listing__country_latest - , user_id AS user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_8 - WHERE listing__country_latest = 'us' - ) subq_9 + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_9.user = users_latest_src_28000.user_id -) subq_12 + listings_latest_src_28000.user_id = users_latest_src_28000.user_id +) subq_8 WHERE listing__country_latest = 'us' GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0.sql index 78c446668c..1d8a2bddf2 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0.sql @@ -1,253 +1,192 @@ -- Pass Only Elements: ['user__home_state_latest',] SELECT - subq_7.user__home_state_latest + subq_4.user__home_state_latest FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.created_at__day + , subq_3.created_at__week + , subq_3.created_at__month + , subq_3.created_at__quarter + , subq_3.created_at__year + , subq_3.created_at__extract_year + , subq_3.created_at__extract_quarter + , subq_3.created_at__extract_month + , subq_3.created_at__extract_day + , subq_3.created_at__extract_dow + , subq_3.created_at__extract_doy + , subq_3.listing__ds__day + , subq_3.listing__ds__week + , subq_3.listing__ds__month + , subq_3.listing__ds__quarter + , subq_3.listing__ds__year + , subq_3.listing__ds__extract_year + , subq_3.listing__ds__extract_quarter + , subq_3.listing__ds__extract_month + , subq_3.listing__ds__extract_day + , subq_3.listing__ds__extract_dow + , subq_3.listing__ds__extract_doy + , subq_3.listing__created_at__day + , subq_3.listing__created_at__week + , subq_3.listing__created_at__month + , subq_3.listing__created_at__quarter + , subq_3.listing__created_at__year + , subq_3.listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month + , subq_3.listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy + , subq_3.listing + , subq_3.user + , subq_3.listing__user + , subq_3.country_latest + , subq_3.is_lux_latest + , subq_3.capacity_latest + , subq_3.listing__country_latest + , subq_3.listing__is_lux_latest + , subq_3.listing__capacity_latest + , subq_3.user__home_state_latest + , subq_3.listings + , subq_3.largest_listing + , subq_3.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_3.ds__day AS ds__day - , subq_3.ds__week AS ds__week - , subq_3.ds__month AS ds__month - , subq_3.ds__quarter AS ds__quarter - , subq_3.ds__year AS ds__year - , subq_3.ds__extract_year AS ds__extract_year - , subq_3.ds__extract_quarter AS ds__extract_quarter - , subq_3.ds__extract_month AS ds__extract_month - , subq_3.ds__extract_day AS ds__extract_day - , subq_3.ds__extract_dow AS ds__extract_dow - , subq_3.ds__extract_doy AS ds__extract_doy - , subq_3.created_at__day AS created_at__day - , subq_3.created_at__week AS created_at__week - , subq_3.created_at__month AS created_at__month - , subq_3.created_at__quarter AS created_at__quarter - , subq_3.created_at__year AS created_at__year - , subq_3.created_at__extract_year AS created_at__extract_year - , subq_3.created_at__extract_quarter AS created_at__extract_quarter - , subq_3.created_at__extract_month AS created_at__extract_month - , subq_3.created_at__extract_day AS created_at__extract_day - , subq_3.created_at__extract_dow AS created_at__extract_dow - , subq_3.created_at__extract_doy AS created_at__extract_doy - , subq_3.listing__ds__day AS listing__ds__day - , subq_3.listing__ds__week AS listing__ds__week - , subq_3.listing__ds__month AS listing__ds__month - , subq_3.listing__ds__quarter AS listing__ds__quarter - , subq_3.listing__ds__year AS listing__ds__year - , subq_3.listing__ds__extract_year AS listing__ds__extract_year - , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_3.listing__ds__extract_month AS listing__ds__extract_month - , subq_3.listing__ds__extract_day AS listing__ds__extract_day - , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_3.listing__created_at__day AS listing__created_at__day - , subq_3.listing__created_at__week AS listing__created_at__week - , subq_3.listing__created_at__month AS listing__created_at__month - , subq_3.listing__created_at__quarter AS listing__created_at__quarter - , subq_3.listing__created_at__year AS listing__created_at__year - , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_3.listing AS listing - , subq_3.user AS user - , subq_3.listing__user AS listing__user - , subq_3.country_latest AS country_latest - , subq_3.is_lux_latest AS is_lux_latest - , subq_3.capacity_latest AS capacity_latest - , subq_3.listing__country_latest AS listing__country_latest - , subq_3.listing__is_lux_latest AS listing__is_lux_latest - , subq_3.listing__capacity_latest AS listing__capacity_latest - , subq_5.home_state_latest AS user__home_state_latest - , subq_3.listings AS listings - , subq_3.largest_listing AS largest_listing - , subq_3.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_2.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_2.ds__day - , subq_2.ds__week - , subq_2.ds__month - , subq_2.ds__quarter - , subq_2.ds__year - , subq_2.ds__extract_year - , subq_2.ds__extract_quarter - , subq_2.ds__extract_month - , subq_2.ds__extract_day - , subq_2.ds__extract_dow - , subq_2.ds__extract_doy - , subq_2.created_at__day - , subq_2.created_at__week - , subq_2.created_at__month - , subq_2.created_at__quarter - , subq_2.created_at__year - , subq_2.created_at__extract_year - , subq_2.created_at__extract_quarter - , subq_2.created_at__extract_month - , subq_2.created_at__extract_day - , subq_2.created_at__extract_dow - , subq_2.created_at__extract_doy - , subq_2.listing__ds__day - , subq_2.listing__ds__week - , subq_2.listing__ds__month - , subq_2.listing__ds__quarter - , subq_2.listing__ds__year - , subq_2.listing__ds__extract_year - , subq_2.listing__ds__extract_quarter - , subq_2.listing__ds__extract_month - , subq_2.listing__ds__extract_day - , subq_2.listing__ds__extract_dow - , subq_2.listing__ds__extract_doy - , subq_2.listing__created_at__day - , subq_2.listing__created_at__week - , subq_2.listing__created_at__month - , subq_2.listing__created_at__quarter - , subq_2.listing__created_at__year - , subq_2.listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month - , subq_2.listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy - , subq_2.listing - , subq_2.user - , subq_2.listing__user - , subq_2.country_latest - , subq_2.is_lux_latest - , subq_2.capacity_latest - , subq_2.listing__country_latest - , subq_2.listing__is_lux_latest - , subq_2.listing__capacity_latest - , subq_2.listings - , subq_2.largest_listing - , subq_2.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 - WHERE listing__country_latest = 'us' - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_1.user + , subq_1.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -277,12 +216,12 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_4 - ) subq_5 + ) subq_1 + ) subq_2 ON - subq_3.user = subq_5.user - ) subq_6 + subq_0.user = subq_2.user + ) subq_3 WHERE listing__country_latest = 'us' -) subq_7 +) subq_4 GROUP BY - subq_7.user__home_state_latest + subq_4.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0_optimized.sql index f2ac976dac..c4e57d3c86 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -5,27 +5,14 @@ SELECT FROM ( -- Join Standard Outputs SELECT - subq_9.listing__country_latest AS listing__country_latest + listings_latest_src_28000.country AS listing__country_latest , users_latest_src_28000.home_state_latest AS user__home_state_latest - FROM ( - -- Constrain Output with WHERE - SELECT - subq_8.user - , listing__country_latest - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - country AS listing__country_latest - , user_id AS user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_8 - WHERE listing__country_latest = 'us' - ) subq_9 + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_9.user = users_latest_src_28000.user_id -) subq_12 + listings_latest_src_28000.user_id = users_latest_src_28000.user_id +) subq_8 WHERE listing__country_latest = 'us' GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0.sql index 9b9dc5ff09..ed1028fb88 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0.sql @@ -1,253 +1,192 @@ -- Pass Only Elements: ['user__home_state_latest',] SELECT - subq_7.user__home_state_latest + subq_4.user__home_state_latest FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.created_at__day + , subq_3.created_at__week + , subq_3.created_at__month + , subq_3.created_at__quarter + , subq_3.created_at__year + , subq_3.created_at__extract_year + , subq_3.created_at__extract_quarter + , subq_3.created_at__extract_month + , subq_3.created_at__extract_day + , subq_3.created_at__extract_dow + , subq_3.created_at__extract_doy + , subq_3.listing__ds__day + , subq_3.listing__ds__week + , subq_3.listing__ds__month + , subq_3.listing__ds__quarter + , subq_3.listing__ds__year + , subq_3.listing__ds__extract_year + , subq_3.listing__ds__extract_quarter + , subq_3.listing__ds__extract_month + , subq_3.listing__ds__extract_day + , subq_3.listing__ds__extract_dow + , subq_3.listing__ds__extract_doy + , subq_3.listing__created_at__day + , subq_3.listing__created_at__week + , subq_3.listing__created_at__month + , subq_3.listing__created_at__quarter + , subq_3.listing__created_at__year + , subq_3.listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month + , subq_3.listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy + , subq_3.listing + , subq_3.user + , subq_3.listing__user + , subq_3.country_latest + , subq_3.is_lux_latest + , subq_3.capacity_latest + , subq_3.listing__country_latest + , subq_3.listing__is_lux_latest + , subq_3.listing__capacity_latest + , subq_3.user__home_state_latest + , subq_3.listings + , subq_3.largest_listing + , subq_3.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_3.ds__day AS ds__day - , subq_3.ds__week AS ds__week - , subq_3.ds__month AS ds__month - , subq_3.ds__quarter AS ds__quarter - , subq_3.ds__year AS ds__year - , subq_3.ds__extract_year AS ds__extract_year - , subq_3.ds__extract_quarter AS ds__extract_quarter - , subq_3.ds__extract_month AS ds__extract_month - , subq_3.ds__extract_day AS ds__extract_day - , subq_3.ds__extract_dow AS ds__extract_dow - , subq_3.ds__extract_doy AS ds__extract_doy - , subq_3.created_at__day AS created_at__day - , subq_3.created_at__week AS created_at__week - , subq_3.created_at__month AS created_at__month - , subq_3.created_at__quarter AS created_at__quarter - , subq_3.created_at__year AS created_at__year - , subq_3.created_at__extract_year AS created_at__extract_year - , subq_3.created_at__extract_quarter AS created_at__extract_quarter - , subq_3.created_at__extract_month AS created_at__extract_month - , subq_3.created_at__extract_day AS created_at__extract_day - , subq_3.created_at__extract_dow AS created_at__extract_dow - , subq_3.created_at__extract_doy AS created_at__extract_doy - , subq_3.listing__ds__day AS listing__ds__day - , subq_3.listing__ds__week AS listing__ds__week - , subq_3.listing__ds__month AS listing__ds__month - , subq_3.listing__ds__quarter AS listing__ds__quarter - , subq_3.listing__ds__year AS listing__ds__year - , subq_3.listing__ds__extract_year AS listing__ds__extract_year - , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_3.listing__ds__extract_month AS listing__ds__extract_month - , subq_3.listing__ds__extract_day AS listing__ds__extract_day - , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_3.listing__created_at__day AS listing__created_at__day - , subq_3.listing__created_at__week AS listing__created_at__week - , subq_3.listing__created_at__month AS listing__created_at__month - , subq_3.listing__created_at__quarter AS listing__created_at__quarter - , subq_3.listing__created_at__year AS listing__created_at__year - , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_3.listing AS listing - , subq_3.user AS user - , subq_3.listing__user AS listing__user - , subq_3.country_latest AS country_latest - , subq_3.is_lux_latest AS is_lux_latest - , subq_3.capacity_latest AS capacity_latest - , subq_3.listing__country_latest AS listing__country_latest - , subq_3.listing__is_lux_latest AS listing__is_lux_latest - , subq_3.listing__capacity_latest AS listing__capacity_latest - , subq_5.home_state_latest AS user__home_state_latest - , subq_3.listings AS listings - , subq_3.largest_listing AS largest_listing - , subq_3.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_2.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_2.ds__day - , subq_2.ds__week - , subq_2.ds__month - , subq_2.ds__quarter - , subq_2.ds__year - , subq_2.ds__extract_year - , subq_2.ds__extract_quarter - , subq_2.ds__extract_month - , subq_2.ds__extract_day - , subq_2.ds__extract_dow - , subq_2.ds__extract_doy - , subq_2.created_at__day - , subq_2.created_at__week - , subq_2.created_at__month - , subq_2.created_at__quarter - , subq_2.created_at__year - , subq_2.created_at__extract_year - , subq_2.created_at__extract_quarter - , subq_2.created_at__extract_month - , subq_2.created_at__extract_day - , subq_2.created_at__extract_dow - , subq_2.created_at__extract_doy - , subq_2.listing__ds__day - , subq_2.listing__ds__week - , subq_2.listing__ds__month - , subq_2.listing__ds__quarter - , subq_2.listing__ds__year - , subq_2.listing__ds__extract_year - , subq_2.listing__ds__extract_quarter - , subq_2.listing__ds__extract_month - , subq_2.listing__ds__extract_day - , subq_2.listing__ds__extract_dow - , subq_2.listing__ds__extract_doy - , subq_2.listing__created_at__day - , subq_2.listing__created_at__week - , subq_2.listing__created_at__month - , subq_2.listing__created_at__quarter - , subq_2.listing__created_at__year - , subq_2.listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month - , subq_2.listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy - , subq_2.listing - , subq_2.user - , subq_2.listing__user - , subq_2.country_latest - , subq_2.is_lux_latest - , subq_2.capacity_latest - , subq_2.listing__country_latest - , subq_2.listing__is_lux_latest - , subq_2.listing__capacity_latest - , subq_2.listings - , subq_2.largest_listing - , subq_2.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 - WHERE listing__country_latest = 'us' - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_1.user + , subq_1.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -277,12 +216,12 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_4 - ) subq_5 + ) subq_1 + ) subq_2 ON - subq_3.user = subq_5.user - ) subq_6 + subq_0.user = subq_2.user + ) subq_3 WHERE listing__country_latest = 'us' -) subq_7 +) subq_4 GROUP BY - subq_7.user__home_state_latest + subq_4.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0_optimized.sql index f2ac976dac..c4e57d3c86 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -5,27 +5,14 @@ SELECT FROM ( -- Join Standard Outputs SELECT - subq_9.listing__country_latest AS listing__country_latest + listings_latest_src_28000.country AS listing__country_latest , users_latest_src_28000.home_state_latest AS user__home_state_latest - FROM ( - -- Constrain Output with WHERE - SELECT - subq_8.user - , listing__country_latest - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - country AS listing__country_latest - , user_id AS user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_8 - WHERE listing__country_latest = 'us' - ) subq_9 + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_9.user = users_latest_src_28000.user_id -) subq_12 + listings_latest_src_28000.user_id = users_latest_src_28000.user_id +) subq_8 WHERE listing__country_latest = 'us' GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0.sql index 46e4dd2a52..c59a5e39af 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0.sql @@ -1,253 +1,192 @@ -- Pass Only Elements: ['user__home_state_latest',] SELECT - subq_7.user__home_state_latest + subq_4.user__home_state_latest FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.created_at__day + , subq_3.created_at__week + , subq_3.created_at__month + , subq_3.created_at__quarter + , subq_3.created_at__year + , subq_3.created_at__extract_year + , subq_3.created_at__extract_quarter + , subq_3.created_at__extract_month + , subq_3.created_at__extract_day + , subq_3.created_at__extract_dow + , subq_3.created_at__extract_doy + , subq_3.listing__ds__day + , subq_3.listing__ds__week + , subq_3.listing__ds__month + , subq_3.listing__ds__quarter + , subq_3.listing__ds__year + , subq_3.listing__ds__extract_year + , subq_3.listing__ds__extract_quarter + , subq_3.listing__ds__extract_month + , subq_3.listing__ds__extract_day + , subq_3.listing__ds__extract_dow + , subq_3.listing__ds__extract_doy + , subq_3.listing__created_at__day + , subq_3.listing__created_at__week + , subq_3.listing__created_at__month + , subq_3.listing__created_at__quarter + , subq_3.listing__created_at__year + , subq_3.listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month + , subq_3.listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy + , subq_3.listing + , subq_3.user + , subq_3.listing__user + , subq_3.country_latest + , subq_3.is_lux_latest + , subq_3.capacity_latest + , subq_3.listing__country_latest + , subq_3.listing__is_lux_latest + , subq_3.listing__capacity_latest + , subq_3.user__home_state_latest + , subq_3.listings + , subq_3.largest_listing + , subq_3.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_3.ds__day AS ds__day - , subq_3.ds__week AS ds__week - , subq_3.ds__month AS ds__month - , subq_3.ds__quarter AS ds__quarter - , subq_3.ds__year AS ds__year - , subq_3.ds__extract_year AS ds__extract_year - , subq_3.ds__extract_quarter AS ds__extract_quarter - , subq_3.ds__extract_month AS ds__extract_month - , subq_3.ds__extract_day AS ds__extract_day - , subq_3.ds__extract_dow AS ds__extract_dow - , subq_3.ds__extract_doy AS ds__extract_doy - , subq_3.created_at__day AS created_at__day - , subq_3.created_at__week AS created_at__week - , subq_3.created_at__month AS created_at__month - , subq_3.created_at__quarter AS created_at__quarter - , subq_3.created_at__year AS created_at__year - , subq_3.created_at__extract_year AS created_at__extract_year - , subq_3.created_at__extract_quarter AS created_at__extract_quarter - , subq_3.created_at__extract_month AS created_at__extract_month - , subq_3.created_at__extract_day AS created_at__extract_day - , subq_3.created_at__extract_dow AS created_at__extract_dow - , subq_3.created_at__extract_doy AS created_at__extract_doy - , subq_3.listing__ds__day AS listing__ds__day - , subq_3.listing__ds__week AS listing__ds__week - , subq_3.listing__ds__month AS listing__ds__month - , subq_3.listing__ds__quarter AS listing__ds__quarter - , subq_3.listing__ds__year AS listing__ds__year - , subq_3.listing__ds__extract_year AS listing__ds__extract_year - , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_3.listing__ds__extract_month AS listing__ds__extract_month - , subq_3.listing__ds__extract_day AS listing__ds__extract_day - , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_3.listing__created_at__day AS listing__created_at__day - , subq_3.listing__created_at__week AS listing__created_at__week - , subq_3.listing__created_at__month AS listing__created_at__month - , subq_3.listing__created_at__quarter AS listing__created_at__quarter - , subq_3.listing__created_at__year AS listing__created_at__year - , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_3.listing AS listing - , subq_3.user AS user - , subq_3.listing__user AS listing__user - , subq_3.country_latest AS country_latest - , subq_3.is_lux_latest AS is_lux_latest - , subq_3.capacity_latest AS capacity_latest - , subq_3.listing__country_latest AS listing__country_latest - , subq_3.listing__is_lux_latest AS listing__is_lux_latest - , subq_3.listing__capacity_latest AS listing__capacity_latest - , subq_5.home_state_latest AS user__home_state_latest - , subq_3.listings AS listings - , subq_3.largest_listing AS largest_listing - , subq_3.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_2.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_2.ds__day - , subq_2.ds__week - , subq_2.ds__month - , subq_2.ds__quarter - , subq_2.ds__year - , subq_2.ds__extract_year - , subq_2.ds__extract_quarter - , subq_2.ds__extract_month - , subq_2.ds__extract_day - , subq_2.ds__extract_dow - , subq_2.ds__extract_doy - , subq_2.created_at__day - , subq_2.created_at__week - , subq_2.created_at__month - , subq_2.created_at__quarter - , subq_2.created_at__year - , subq_2.created_at__extract_year - , subq_2.created_at__extract_quarter - , subq_2.created_at__extract_month - , subq_2.created_at__extract_day - , subq_2.created_at__extract_dow - , subq_2.created_at__extract_doy - , subq_2.listing__ds__day - , subq_2.listing__ds__week - , subq_2.listing__ds__month - , subq_2.listing__ds__quarter - , subq_2.listing__ds__year - , subq_2.listing__ds__extract_year - , subq_2.listing__ds__extract_quarter - , subq_2.listing__ds__extract_month - , subq_2.listing__ds__extract_day - , subq_2.listing__ds__extract_dow - , subq_2.listing__ds__extract_doy - , subq_2.listing__created_at__day - , subq_2.listing__created_at__week - , subq_2.listing__created_at__month - , subq_2.listing__created_at__quarter - , subq_2.listing__created_at__year - , subq_2.listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month - , subq_2.listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy - , subq_2.listing - , subq_2.user - , subq_2.listing__user - , subq_2.country_latest - , subq_2.is_lux_latest - , subq_2.capacity_latest - , subq_2.listing__country_latest - , subq_2.listing__is_lux_latest - , subq_2.listing__capacity_latest - , subq_2.listings - , subq_2.largest_listing - , subq_2.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 - WHERE listing__country_latest = 'us' - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_1.user + , subq_1.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -277,12 +216,12 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_4 - ) subq_5 + ) subq_1 + ) subq_2 ON - subq_3.user = subq_5.user - ) subq_6 + subq_0.user = subq_2.user + ) subq_3 WHERE listing__country_latest = 'us' -) subq_7 +) subq_4 GROUP BY - subq_7.user__home_state_latest + subq_4.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0_optimized.sql index f2ac976dac..c4e57d3c86 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -5,27 +5,14 @@ SELECT FROM ( -- Join Standard Outputs SELECT - subq_9.listing__country_latest AS listing__country_latest + listings_latest_src_28000.country AS listing__country_latest , users_latest_src_28000.home_state_latest AS user__home_state_latest - FROM ( - -- Constrain Output with WHERE - SELECT - subq_8.user - , listing__country_latest - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - country AS listing__country_latest - , user_id AS user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_8 - WHERE listing__country_latest = 'us' - ) subq_9 + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_9.user = users_latest_src_28000.user_id -) subq_12 + listings_latest_src_28000.user_id = users_latest_src_28000.user_id +) subq_8 WHERE listing__country_latest = 'us' GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0.sql index e7670aac55..d1dedc82a3 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0.sql @@ -1,253 +1,192 @@ -- Pass Only Elements: ['user__home_state_latest',] SELECT - subq_7.user__home_state_latest + subq_4.user__home_state_latest FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.created_at__day + , subq_3.created_at__week + , subq_3.created_at__month + , subq_3.created_at__quarter + , subq_3.created_at__year + , subq_3.created_at__extract_year + , subq_3.created_at__extract_quarter + , subq_3.created_at__extract_month + , subq_3.created_at__extract_day + , subq_3.created_at__extract_dow + , subq_3.created_at__extract_doy + , subq_3.listing__ds__day + , subq_3.listing__ds__week + , subq_3.listing__ds__month + , subq_3.listing__ds__quarter + , subq_3.listing__ds__year + , subq_3.listing__ds__extract_year + , subq_3.listing__ds__extract_quarter + , subq_3.listing__ds__extract_month + , subq_3.listing__ds__extract_day + , subq_3.listing__ds__extract_dow + , subq_3.listing__ds__extract_doy + , subq_3.listing__created_at__day + , subq_3.listing__created_at__week + , subq_3.listing__created_at__month + , subq_3.listing__created_at__quarter + , subq_3.listing__created_at__year + , subq_3.listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month + , subq_3.listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy + , subq_3.listing + , subq_3.user + , subq_3.listing__user + , subq_3.country_latest + , subq_3.is_lux_latest + , subq_3.capacity_latest + , subq_3.listing__country_latest + , subq_3.listing__is_lux_latest + , subq_3.listing__capacity_latest + , subq_3.user__home_state_latest + , subq_3.listings + , subq_3.largest_listing + , subq_3.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_3.ds__day AS ds__day - , subq_3.ds__week AS ds__week - , subq_3.ds__month AS ds__month - , subq_3.ds__quarter AS ds__quarter - , subq_3.ds__year AS ds__year - , subq_3.ds__extract_year AS ds__extract_year - , subq_3.ds__extract_quarter AS ds__extract_quarter - , subq_3.ds__extract_month AS ds__extract_month - , subq_3.ds__extract_day AS ds__extract_day - , subq_3.ds__extract_dow AS ds__extract_dow - , subq_3.ds__extract_doy AS ds__extract_doy - , subq_3.created_at__day AS created_at__day - , subq_3.created_at__week AS created_at__week - , subq_3.created_at__month AS created_at__month - , subq_3.created_at__quarter AS created_at__quarter - , subq_3.created_at__year AS created_at__year - , subq_3.created_at__extract_year AS created_at__extract_year - , subq_3.created_at__extract_quarter AS created_at__extract_quarter - , subq_3.created_at__extract_month AS created_at__extract_month - , subq_3.created_at__extract_day AS created_at__extract_day - , subq_3.created_at__extract_dow AS created_at__extract_dow - , subq_3.created_at__extract_doy AS created_at__extract_doy - , subq_3.listing__ds__day AS listing__ds__day - , subq_3.listing__ds__week AS listing__ds__week - , subq_3.listing__ds__month AS listing__ds__month - , subq_3.listing__ds__quarter AS listing__ds__quarter - , subq_3.listing__ds__year AS listing__ds__year - , subq_3.listing__ds__extract_year AS listing__ds__extract_year - , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_3.listing__ds__extract_month AS listing__ds__extract_month - , subq_3.listing__ds__extract_day AS listing__ds__extract_day - , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_3.listing__created_at__day AS listing__created_at__day - , subq_3.listing__created_at__week AS listing__created_at__week - , subq_3.listing__created_at__month AS listing__created_at__month - , subq_3.listing__created_at__quarter AS listing__created_at__quarter - , subq_3.listing__created_at__year AS listing__created_at__year - , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_3.listing AS listing - , subq_3.user AS user - , subq_3.listing__user AS listing__user - , subq_3.country_latest AS country_latest - , subq_3.is_lux_latest AS is_lux_latest - , subq_3.capacity_latest AS capacity_latest - , subq_3.listing__country_latest AS listing__country_latest - , subq_3.listing__is_lux_latest AS listing__is_lux_latest - , subq_3.listing__capacity_latest AS listing__capacity_latest - , subq_5.home_state_latest AS user__home_state_latest - , subq_3.listings AS listings - , subq_3.largest_listing AS largest_listing - , subq_3.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_2.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_2.ds__day - , subq_2.ds__week - , subq_2.ds__month - , subq_2.ds__quarter - , subq_2.ds__year - , subq_2.ds__extract_year - , subq_2.ds__extract_quarter - , subq_2.ds__extract_month - , subq_2.ds__extract_day - , subq_2.ds__extract_dow - , subq_2.ds__extract_doy - , subq_2.created_at__day - , subq_2.created_at__week - , subq_2.created_at__month - , subq_2.created_at__quarter - , subq_2.created_at__year - , subq_2.created_at__extract_year - , subq_2.created_at__extract_quarter - , subq_2.created_at__extract_month - , subq_2.created_at__extract_day - , subq_2.created_at__extract_dow - , subq_2.created_at__extract_doy - , subq_2.listing__ds__day - , subq_2.listing__ds__week - , subq_2.listing__ds__month - , subq_2.listing__ds__quarter - , subq_2.listing__ds__year - , subq_2.listing__ds__extract_year - , subq_2.listing__ds__extract_quarter - , subq_2.listing__ds__extract_month - , subq_2.listing__ds__extract_day - , subq_2.listing__ds__extract_dow - , subq_2.listing__ds__extract_doy - , subq_2.listing__created_at__day - , subq_2.listing__created_at__week - , subq_2.listing__created_at__month - , subq_2.listing__created_at__quarter - , subq_2.listing__created_at__year - , subq_2.listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month - , subq_2.listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy - , subq_2.listing - , subq_2.user - , subq_2.listing__user - , subq_2.country_latest - , subq_2.is_lux_latest - , subq_2.capacity_latest - , subq_2.listing__country_latest - , subq_2.listing__is_lux_latest - , subq_2.listing__capacity_latest - , subq_2.listings - , subq_2.largest_listing - , subq_2.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 - WHERE listing__country_latest = 'us' - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_1.user + , subq_1.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -277,12 +216,12 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_4 - ) subq_5 + ) subq_1 + ) subq_2 ON - subq_3.user = subq_5.user - ) subq_6 + subq_0.user = subq_2.user + ) subq_3 WHERE listing__country_latest = 'us' -) subq_7 +) subq_4 GROUP BY - subq_7.user__home_state_latest + subq_4.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0_optimized.sql index f2ac976dac..c4e57d3c86 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -5,27 +5,14 @@ SELECT FROM ( -- Join Standard Outputs SELECT - subq_9.listing__country_latest AS listing__country_latest + listings_latest_src_28000.country AS listing__country_latest , users_latest_src_28000.home_state_latest AS user__home_state_latest - FROM ( - -- Constrain Output with WHERE - SELECT - subq_8.user - , listing__country_latest - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - country AS listing__country_latest - , user_id AS user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_8 - WHERE listing__country_latest = 'us' - ) subq_9 + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_9.user = users_latest_src_28000.user_id -) subq_12 + listings_latest_src_28000.user_id = users_latest_src_28000.user_id +) subq_8 WHERE listing__country_latest = 'us' GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimension_with_joined_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimension_with_joined_where_constraint__plan0.sql index 0f8d5830a6..c30f2c64e7 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimension_with_joined_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimension_with_joined_where_constraint__plan0.sql @@ -1,253 +1,192 @@ -- Pass Only Elements: ['user__home_state_latest',] SELECT - subq_7.user__home_state_latest + subq_4.user__home_state_latest FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.created_at__day + , subq_3.created_at__week + , subq_3.created_at__month + , subq_3.created_at__quarter + , subq_3.created_at__year + , subq_3.created_at__extract_year + , subq_3.created_at__extract_quarter + , subq_3.created_at__extract_month + , subq_3.created_at__extract_day + , subq_3.created_at__extract_dow + , subq_3.created_at__extract_doy + , subq_3.listing__ds__day + , subq_3.listing__ds__week + , subq_3.listing__ds__month + , subq_3.listing__ds__quarter + , subq_3.listing__ds__year + , subq_3.listing__ds__extract_year + , subq_3.listing__ds__extract_quarter + , subq_3.listing__ds__extract_month + , subq_3.listing__ds__extract_day + , subq_3.listing__ds__extract_dow + , subq_3.listing__ds__extract_doy + , subq_3.listing__created_at__day + , subq_3.listing__created_at__week + , subq_3.listing__created_at__month + , subq_3.listing__created_at__quarter + , subq_3.listing__created_at__year + , subq_3.listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month + , subq_3.listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy + , subq_3.listing + , subq_3.user + , subq_3.listing__user + , subq_3.country_latest + , subq_3.is_lux_latest + , subq_3.capacity_latest + , subq_3.listing__country_latest + , subq_3.listing__is_lux_latest + , subq_3.listing__capacity_latest + , subq_3.user__home_state_latest + , subq_3.listings + , subq_3.largest_listing + , subq_3.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_3.ds__day AS ds__day - , subq_3.ds__week AS ds__week - , subq_3.ds__month AS ds__month - , subq_3.ds__quarter AS ds__quarter - , subq_3.ds__year AS ds__year - , subq_3.ds__extract_year AS ds__extract_year - , subq_3.ds__extract_quarter AS ds__extract_quarter - , subq_3.ds__extract_month AS ds__extract_month - , subq_3.ds__extract_day AS ds__extract_day - , subq_3.ds__extract_dow AS ds__extract_dow - , subq_3.ds__extract_doy AS ds__extract_doy - , subq_3.created_at__day AS created_at__day - , subq_3.created_at__week AS created_at__week - , subq_3.created_at__month AS created_at__month - , subq_3.created_at__quarter AS created_at__quarter - , subq_3.created_at__year AS created_at__year - , subq_3.created_at__extract_year AS created_at__extract_year - , subq_3.created_at__extract_quarter AS created_at__extract_quarter - , subq_3.created_at__extract_month AS created_at__extract_month - , subq_3.created_at__extract_day AS created_at__extract_day - , subq_3.created_at__extract_dow AS created_at__extract_dow - , subq_3.created_at__extract_doy AS created_at__extract_doy - , subq_3.listing__ds__day AS listing__ds__day - , subq_3.listing__ds__week AS listing__ds__week - , subq_3.listing__ds__month AS listing__ds__month - , subq_3.listing__ds__quarter AS listing__ds__quarter - , subq_3.listing__ds__year AS listing__ds__year - , subq_3.listing__ds__extract_year AS listing__ds__extract_year - , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_3.listing__ds__extract_month AS listing__ds__extract_month - , subq_3.listing__ds__extract_day AS listing__ds__extract_day - , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_3.listing__created_at__day AS listing__created_at__day - , subq_3.listing__created_at__week AS listing__created_at__week - , subq_3.listing__created_at__month AS listing__created_at__month - , subq_3.listing__created_at__quarter AS listing__created_at__quarter - , subq_3.listing__created_at__year AS listing__created_at__year - , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_3.listing AS listing - , subq_3.user AS user - , subq_3.listing__user AS listing__user - , subq_3.country_latest AS country_latest - , subq_3.is_lux_latest AS is_lux_latest - , subq_3.capacity_latest AS capacity_latest - , subq_3.listing__country_latest AS listing__country_latest - , subq_3.listing__is_lux_latest AS listing__is_lux_latest - , subq_3.listing__capacity_latest AS listing__capacity_latest - , subq_5.home_state_latest AS user__home_state_latest - , subq_3.listings AS listings - , subq_3.largest_listing AS largest_listing - , subq_3.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_2.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_2.ds__day - , subq_2.ds__week - , subq_2.ds__month - , subq_2.ds__quarter - , subq_2.ds__year - , subq_2.ds__extract_year - , subq_2.ds__extract_quarter - , subq_2.ds__extract_month - , subq_2.ds__extract_day - , subq_2.ds__extract_dow - , subq_2.ds__extract_doy - , subq_2.created_at__day - , subq_2.created_at__week - , subq_2.created_at__month - , subq_2.created_at__quarter - , subq_2.created_at__year - , subq_2.created_at__extract_year - , subq_2.created_at__extract_quarter - , subq_2.created_at__extract_month - , subq_2.created_at__extract_day - , subq_2.created_at__extract_dow - , subq_2.created_at__extract_doy - , subq_2.listing__ds__day - , subq_2.listing__ds__week - , subq_2.listing__ds__month - , subq_2.listing__ds__quarter - , subq_2.listing__ds__year - , subq_2.listing__ds__extract_year - , subq_2.listing__ds__extract_quarter - , subq_2.listing__ds__extract_month - , subq_2.listing__ds__extract_day - , subq_2.listing__ds__extract_dow - , subq_2.listing__ds__extract_doy - , subq_2.listing__created_at__day - , subq_2.listing__created_at__week - , subq_2.listing__created_at__month - , subq_2.listing__created_at__quarter - , subq_2.listing__created_at__year - , subq_2.listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month - , subq_2.listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy - , subq_2.listing - , subq_2.user - , subq_2.listing__user - , subq_2.country_latest - , subq_2.is_lux_latest - , subq_2.capacity_latest - , subq_2.listing__country_latest - , subq_2.listing__is_lux_latest - , subq_2.listing__capacity_latest - , subq_2.listings - , subq_2.largest_listing - , subq_2.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 - WHERE listing__country_latest = 'us' - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_1.user + , subq_1.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -277,12 +216,12 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_4 - ) subq_5 + ) subq_1 + ) subq_2 ON - subq_3.user = subq_5.user - ) subq_6 + subq_0.user = subq_2.user + ) subq_3 WHERE listing__country_latest = 'us' -) subq_7 +) subq_4 GROUP BY - subq_7.user__home_state_latest + subq_4.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimension_with_joined_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimension_with_joined_where_constraint__plan0_optimized.sql index f2ac976dac..c4e57d3c86 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimension_with_joined_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_dimension_with_joined_where_constraint__plan0_optimized.sql @@ -5,27 +5,14 @@ SELECT FROM ( -- Join Standard Outputs SELECT - subq_9.listing__country_latest AS listing__country_latest + listings_latest_src_28000.country AS listing__country_latest , users_latest_src_28000.home_state_latest AS user__home_state_latest - FROM ( - -- Constrain Output with WHERE - SELECT - subq_8.user - , listing__country_latest - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - country AS listing__country_latest - , user_id AS user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_8 - WHERE listing__country_latest = 'us' - ) subq_9 + FROM ***************************.dim_listings_latest listings_latest_src_28000 FULL OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_9.user = users_latest_src_28000.user_id -) subq_12 + listings_latest_src_28000.user_id = users_latest_src_28000.user_id +) subq_8 WHERE listing__country_latest = 'us' GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_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 61b7bee195..b3e9e7e915 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_30.average_booking_value) AS average_booking_value - , MAX(subq_43.bookings) AS bookings - , MAX(subq_51.booking_value) AS booking_value + MAX(subq_18.average_booking_value) AS average_booking_value + , MAX(subq_31.bookings) AS bookings + , MAX(subq_39.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_29.average_booking_value + subq_17.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_28.average_booking_value) AS average_booking_value + AVG(subq_16.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_27.average_booking_value + subq_15.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.listing__is_lux_latest - , subq_26.average_booking_value + subq_14.booking__is_instant + , subq_14.listing__is_lux_latest + , subq_14.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_25.booking__is_instant - , subq_25.listing__is_lux_latest - , subq_25.average_booking_value + subq_13.booking__is_instant + , subq_13.listing__is_lux_latest + , subq_13.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_21.listing AS listing - , subq_21.booking__is_instant AS booking__is_instant - , subq_24.is_lux_latest AS listing__is_lux_latest - , subq_21.average_booking_value AS average_booking_value + subq_9.listing AS listing + , subq_9.booking__is_instant AS booking__is_instant + , subq_12.is_lux_latest AS listing__is_lux_latest + , subq_9.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_20.listing - , subq_20.booking__is_instant - , subq_20.average_booking_value + subq_8.listing + , subq_8.booking__is_instant + , subq_8.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_19.ds__day - , subq_19.ds__week - , subq_19.ds__month - , subq_19.ds__quarter - , subq_19.ds__year - , subq_19.ds__extract_year - , subq_19.ds__extract_quarter - , subq_19.ds__extract_month - , subq_19.ds__extract_day - , subq_19.ds__extract_dow - , subq_19.ds__extract_doy - , subq_19.ds_partitioned__day - , subq_19.ds_partitioned__week - , subq_19.ds_partitioned__month - , subq_19.ds_partitioned__quarter - , subq_19.ds_partitioned__year - , subq_19.ds_partitioned__extract_year - , subq_19.ds_partitioned__extract_quarter - , subq_19.ds_partitioned__extract_month - , subq_19.ds_partitioned__extract_day - , subq_19.ds_partitioned__extract_dow - , subq_19.ds_partitioned__extract_doy - , subq_19.paid_at__day - , subq_19.paid_at__week - , subq_19.paid_at__month - , subq_19.paid_at__quarter - , subq_19.paid_at__year - , subq_19.paid_at__extract_year - , subq_19.paid_at__extract_quarter - , subq_19.paid_at__extract_month - , subq_19.paid_at__extract_day - , subq_19.paid_at__extract_dow - , subq_19.paid_at__extract_doy - , subq_19.booking__ds__day - , subq_19.booking__ds__week - , subq_19.booking__ds__month - , subq_19.booking__ds__quarter - , subq_19.booking__ds__year - , subq_19.booking__ds__extract_year - , subq_19.booking__ds__extract_quarter - , subq_19.booking__ds__extract_month - , subq_19.booking__ds__extract_day - , subq_19.booking__ds__extract_dow - , subq_19.booking__ds__extract_doy - , subq_19.booking__ds_partitioned__day - , subq_19.booking__ds_partitioned__week - , subq_19.booking__ds_partitioned__month - , subq_19.booking__ds_partitioned__quarter - , subq_19.booking__ds_partitioned__year - , subq_19.booking__ds_partitioned__extract_year - , subq_19.booking__ds_partitioned__extract_quarter - , subq_19.booking__ds_partitioned__extract_month - , subq_19.booking__ds_partitioned__extract_day - , subq_19.booking__ds_partitioned__extract_dow - , subq_19.booking__ds_partitioned__extract_doy - , subq_19.booking__paid_at__day - , subq_19.booking__paid_at__week - , subq_19.booking__paid_at__month - , subq_19.booking__paid_at__quarter - , subq_19.booking__paid_at__year - , subq_19.booking__paid_at__extract_year - , subq_19.booking__paid_at__extract_quarter - , subq_19.booking__paid_at__extract_month - , subq_19.booking__paid_at__extract_day - , subq_19.booking__paid_at__extract_dow - , subq_19.booking__paid_at__extract_doy - , subq_19.metric_time__day - , subq_19.metric_time__week - , subq_19.metric_time__month - , subq_19.metric_time__quarter - , subq_19.metric_time__year - , subq_19.metric_time__extract_year - , subq_19.metric_time__extract_quarter - , subq_19.metric_time__extract_month - , subq_19.metric_time__extract_day - , subq_19.metric_time__extract_dow - , subq_19.metric_time__extract_doy - , subq_19.listing - , subq_19.guest - , subq_19.host - , subq_19.booking__listing - , subq_19.booking__guest - , subq_19.booking__host - , subq_19.is_instant - , subq_19.booking__is_instant - , subq_19.bookings - , subq_19.instant_bookings - , subq_19.booking_value - , subq_19.max_booking_value - , subq_19.min_booking_value - , subq_19.bookers - , subq_19.average_booking_value - , subq_19.referred_bookings - , subq_19.median_booking_value - , subq_19.booking_value_p99 - , subq_19.discrete_booking_value_p99 - , subq_19.approximate_continuous_booking_value_p99 - , subq_19.approximate_discrete_booking_value_p99 + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.ds_partitioned__day + , subq_7.ds_partitioned__week + , subq_7.ds_partitioned__month + , subq_7.ds_partitioned__quarter + , subq_7.ds_partitioned__year + , subq_7.ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy + , subq_7.paid_at__day + , subq_7.paid_at__week + , subq_7.paid_at__month + , subq_7.paid_at__quarter + , subq_7.paid_at__year + , subq_7.paid_at__extract_year + , subq_7.paid_at__extract_quarter + , subq_7.paid_at__extract_month + , subq_7.paid_at__extract_day + , subq_7.paid_at__extract_dow + , subq_7.paid_at__extract_doy + , subq_7.booking__ds__day + , subq_7.booking__ds__week + , subq_7.booking__ds__month + , subq_7.booking__ds__quarter + , subq_7.booking__ds__year + , subq_7.booking__ds__extract_year + , subq_7.booking__ds__extract_quarter + , subq_7.booking__ds__extract_month + , subq_7.booking__ds__extract_day + , subq_7.booking__ds__extract_dow + , subq_7.booking__ds__extract_doy + , subq_7.booking__ds_partitioned__day + , subq_7.booking__ds_partitioned__week + , subq_7.booking__ds_partitioned__month + , subq_7.booking__ds_partitioned__quarter + , subq_7.booking__ds_partitioned__year + , subq_7.booking__ds_partitioned__extract_year + , subq_7.booking__ds_partitioned__extract_quarter + , subq_7.booking__ds_partitioned__extract_month + , subq_7.booking__ds_partitioned__extract_day + , subq_7.booking__ds_partitioned__extract_dow + , subq_7.booking__ds_partitioned__extract_doy + , subq_7.booking__paid_at__day + , subq_7.booking__paid_at__week + , subq_7.booking__paid_at__month + , subq_7.booking__paid_at__quarter + , subq_7.booking__paid_at__year + , subq_7.booking__paid_at__extract_year + , subq_7.booking__paid_at__extract_quarter + , subq_7.booking__paid_at__extract_month + , subq_7.booking__paid_at__extract_day + , subq_7.booking__paid_at__extract_dow + , subq_7.booking__paid_at__extract_doy + , subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.metric_time__month + , subq_7.metric_time__quarter + , subq_7.metric_time__year + , subq_7.metric_time__extract_year + , subq_7.metric_time__extract_quarter + , subq_7.metric_time__extract_month + , subq_7.metric_time__extract_day + , subq_7.metric_time__extract_dow + , subq_7.metric_time__extract_doy + , subq_7.listing + , subq_7.guest + , subq_7.host + , subq_7.booking__listing + , subq_7.booking__guest + , subq_7.booking__host + , subq_7.is_instant + , subq_7.booking__is_instant + , subq_7.bookings + , subq_7.instant_bookings + , subq_7.booking_value + , subq_7.max_booking_value + , subq_7.min_booking_value + , subq_7.bookers + , subq_7.average_booking_value + , subq_7.referred_bookings + , subq_7.median_booking_value + , subq_7.booking_value_p99 + , subq_7.discrete_booking_value_p99 + , subq_7.approximate_continuous_booking_value_p99 + , subq_7.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.ds_partitioned__day - , subq_18.ds_partitioned__week - , subq_18.ds_partitioned__month - , subq_18.ds_partitioned__quarter - , subq_18.ds_partitioned__year - , subq_18.ds_partitioned__extract_year - , subq_18.ds_partitioned__extract_quarter - , subq_18.ds_partitioned__extract_month - , subq_18.ds_partitioned__extract_day - , subq_18.ds_partitioned__extract_dow - , subq_18.ds_partitioned__extract_doy - , subq_18.paid_at__day - , subq_18.paid_at__week - , subq_18.paid_at__month - , subq_18.paid_at__quarter - , subq_18.paid_at__year - , subq_18.paid_at__extract_year - , subq_18.paid_at__extract_quarter - , subq_18.paid_at__extract_month - , subq_18.paid_at__extract_day - , subq_18.paid_at__extract_dow - , subq_18.paid_at__extract_doy - , subq_18.booking__ds__day - , subq_18.booking__ds__week - , subq_18.booking__ds__month - , subq_18.booking__ds__quarter - , subq_18.booking__ds__year - , subq_18.booking__ds__extract_year - , subq_18.booking__ds__extract_quarter - , subq_18.booking__ds__extract_month - , subq_18.booking__ds__extract_day - , subq_18.booking__ds__extract_dow - , subq_18.booking__ds__extract_doy - , subq_18.booking__ds_partitioned__day - , subq_18.booking__ds_partitioned__week - , subq_18.booking__ds_partitioned__month - , subq_18.booking__ds_partitioned__quarter - , subq_18.booking__ds_partitioned__year - , subq_18.booking__ds_partitioned__extract_year - , subq_18.booking__ds_partitioned__extract_quarter - , subq_18.booking__ds_partitioned__extract_month - , subq_18.booking__ds_partitioned__extract_day - , subq_18.booking__ds_partitioned__extract_dow - , subq_18.booking__ds_partitioned__extract_doy - , subq_18.booking__paid_at__day - , subq_18.booking__paid_at__week - , subq_18.booking__paid_at__month - , subq_18.booking__paid_at__quarter - , subq_18.booking__paid_at__year - , subq_18.booking__paid_at__extract_year - , subq_18.booking__paid_at__extract_quarter - , subq_18.booking__paid_at__extract_month - , subq_18.booking__paid_at__extract_day - , subq_18.booking__paid_at__extract_dow - , subq_18.booking__paid_at__extract_doy - , subq_18.ds__day AS metric_time__day - , subq_18.ds__week AS metric_time__week - , subq_18.ds__month AS metric_time__month - , subq_18.ds__quarter AS metric_time__quarter - , subq_18.ds__year AS metric_time__year - , subq_18.ds__extract_year AS metric_time__extract_year - , subq_18.ds__extract_quarter AS metric_time__extract_quarter - , subq_18.ds__extract_month AS metric_time__extract_month - , subq_18.ds__extract_day AS metric_time__extract_day - , subq_18.ds__extract_dow AS metric_time__extract_dow - , subq_18.ds__extract_doy AS metric_time__extract_doy - , subq_18.listing - , subq_18.guest - , subq_18.host - , subq_18.booking__listing - , subq_18.booking__guest - , subq_18.booking__host - , subq_18.is_instant - , subq_18.booking__is_instant - , subq_18.bookings - , subq_18.instant_bookings - , subq_18.booking_value - , subq_18.max_booking_value - , subq_18.min_booking_value - , subq_18.bookers - , subq_18.average_booking_value - , subq_18.referred_bookings - , subq_18.median_booking_value - , subq_18.booking_value_p99 - , subq_18.discrete_booking_value_p99 - , subq_18.approximate_continuous_booking_value_p99 - , subq_18.approximate_discrete_booking_value_p99 + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -342,86 +342,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_18 - ) subq_19 + ) subq_6 + ) subq_7 WHERE booking__is_instant - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_23.listing - , subq_23.is_lux_latest + subq_11.listing + , subq_11.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_22.ds__day - , subq_22.ds__week - , subq_22.ds__month - , subq_22.ds__quarter - , subq_22.ds__year - , subq_22.ds__extract_year - , subq_22.ds__extract_quarter - , subq_22.ds__extract_month - , subq_22.ds__extract_day - , subq_22.ds__extract_dow - , subq_22.ds__extract_doy - , subq_22.created_at__day - , subq_22.created_at__week - , subq_22.created_at__month - , subq_22.created_at__quarter - , subq_22.created_at__year - , subq_22.created_at__extract_year - , subq_22.created_at__extract_quarter - , subq_22.created_at__extract_month - , subq_22.created_at__extract_day - , subq_22.created_at__extract_dow - , subq_22.created_at__extract_doy - , subq_22.listing__ds__day - , subq_22.listing__ds__week - , subq_22.listing__ds__month - , subq_22.listing__ds__quarter - , subq_22.listing__ds__year - , subq_22.listing__ds__extract_year - , subq_22.listing__ds__extract_quarter - , subq_22.listing__ds__extract_month - , subq_22.listing__ds__extract_day - , subq_22.listing__ds__extract_dow - , subq_22.listing__ds__extract_doy - , subq_22.listing__created_at__day - , subq_22.listing__created_at__week - , subq_22.listing__created_at__month - , subq_22.listing__created_at__quarter - , subq_22.listing__created_at__year - , subq_22.listing__created_at__extract_year - , subq_22.listing__created_at__extract_quarter - , subq_22.listing__created_at__extract_month - , subq_22.listing__created_at__extract_day - , subq_22.listing__created_at__extract_dow - , subq_22.listing__created_at__extract_doy - , subq_22.ds__day AS metric_time__day - , subq_22.ds__week AS metric_time__week - , subq_22.ds__month AS metric_time__month - , subq_22.ds__quarter AS metric_time__quarter - , subq_22.ds__year AS metric_time__year - , subq_22.ds__extract_year AS metric_time__extract_year - , subq_22.ds__extract_quarter AS metric_time__extract_quarter - , subq_22.ds__extract_month AS metric_time__extract_month - , subq_22.ds__extract_day AS metric_time__extract_day - , subq_22.ds__extract_dow AS metric_time__extract_dow - , subq_22.ds__extract_doy AS metric_time__extract_doy - , subq_22.listing - , subq_22.user - , subq_22.listing__user - , subq_22.country_latest - , subq_22.is_lux_latest - , subq_22.capacity_latest - , subq_22.listing__country_latest - , subq_22.listing__is_lux_latest - , subq_22.listing__capacity_latest - , subq_22.listings - , subq_22.largest_listing - , subq_22.smallest_listing + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.created_at__day + , subq_10.created_at__week + , subq_10.created_at__month + , subq_10.created_at__quarter + , subq_10.created_at__year + , subq_10.created_at__extract_year + , subq_10.created_at__extract_quarter + , subq_10.created_at__extract_month + , subq_10.created_at__extract_day + , subq_10.created_at__extract_dow + , subq_10.created_at__extract_doy + , subq_10.listing__ds__day + , subq_10.listing__ds__week + , subq_10.listing__ds__month + , subq_10.listing__ds__quarter + , subq_10.listing__ds__year + , subq_10.listing__ds__extract_year + , subq_10.listing__ds__extract_quarter + , subq_10.listing__ds__extract_month + , subq_10.listing__ds__extract_day + , subq_10.listing__ds__extract_dow + , subq_10.listing__ds__extract_doy + , subq_10.listing__created_at__day + , subq_10.listing__created_at__week + , subq_10.listing__created_at__month + , subq_10.listing__created_at__quarter + , subq_10.listing__created_at__year + , subq_10.listing__created_at__extract_year + , subq_10.listing__created_at__extract_quarter + , subq_10.listing__created_at__extract_month + , subq_10.listing__created_at__extract_day + , subq_10.listing__created_at__extract_dow + , subq_10.listing__created_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.user + , subq_10.listing__user + , subq_10.country_latest + , subq_10.is_lux_latest + , subq_10.capacity_latest + , subq_10.listing__country_latest + , subq_10.listing__is_lux_latest + , subq_10.listing__capacity_latest + , subq_10.listings + , subq_10.largest_listing + , subq_10.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -482,257 +482,257 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 - ) subq_23 - ) subq_24 + ) subq_10 + ) subq_11 + ) subq_12 ON - subq_21.listing = subq_24.listing - ) subq_25 - ) subq_26 + subq_9.listing = subq_12.listing + ) subq_13 + ) subq_14 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 + ) subq_15 + ) subq_16 + ) subq_17 + ) subq_18 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_42.bookings + subq_30.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_41.bookings) AS bookings + SUM(subq_29.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_40.bookings + subq_28.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_39.booking__is_instant - , subq_39.listing__is_lux_latest - , subq_39.bookings + subq_27.booking__is_instant + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_38.booking__is_instant - , subq_38.listing__is_lux_latest - , subq_38.bookings + subq_26.booking__is_instant + , subq_26.listing__is_lux_latest + , subq_26.bookings FROM ( -- Join Standard Outputs SELECT - subq_34.listing AS listing - , subq_34.booking__is_instant AS booking__is_instant - , subq_37.is_lux_latest AS listing__is_lux_latest - , subq_34.bookings AS bookings + subq_22.listing AS listing + , subq_22.booking__is_instant AS booking__is_instant + , subq_25.is_lux_latest AS listing__is_lux_latest + , subq_22.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_33.listing - , subq_33.booking__is_instant - , subq_33.bookings + subq_21.listing + , subq_21.booking__is_instant + , subq_21.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_32.ds__day - , subq_32.ds__week - , subq_32.ds__month - , subq_32.ds__quarter - , subq_32.ds__year - , subq_32.ds__extract_year - , subq_32.ds__extract_quarter - , subq_32.ds__extract_month - , subq_32.ds__extract_day - , subq_32.ds__extract_dow - , subq_32.ds__extract_doy - , subq_32.ds_partitioned__day - , subq_32.ds_partitioned__week - , subq_32.ds_partitioned__month - , subq_32.ds_partitioned__quarter - , subq_32.ds_partitioned__year - , subq_32.ds_partitioned__extract_year - , subq_32.ds_partitioned__extract_quarter - , subq_32.ds_partitioned__extract_month - , subq_32.ds_partitioned__extract_day - , subq_32.ds_partitioned__extract_dow - , subq_32.ds_partitioned__extract_doy - , subq_32.paid_at__day - , subq_32.paid_at__week - , subq_32.paid_at__month - , subq_32.paid_at__quarter - , subq_32.paid_at__year - , subq_32.paid_at__extract_year - , subq_32.paid_at__extract_quarter - , subq_32.paid_at__extract_month - , subq_32.paid_at__extract_day - , subq_32.paid_at__extract_dow - , subq_32.paid_at__extract_doy - , subq_32.booking__ds__day - , subq_32.booking__ds__week - , subq_32.booking__ds__month - , subq_32.booking__ds__quarter - , subq_32.booking__ds__year - , subq_32.booking__ds__extract_year - , subq_32.booking__ds__extract_quarter - , subq_32.booking__ds__extract_month - , subq_32.booking__ds__extract_day - , subq_32.booking__ds__extract_dow - , subq_32.booking__ds__extract_doy - , subq_32.booking__ds_partitioned__day - , subq_32.booking__ds_partitioned__week - , subq_32.booking__ds_partitioned__month - , subq_32.booking__ds_partitioned__quarter - , subq_32.booking__ds_partitioned__year - , subq_32.booking__ds_partitioned__extract_year - , subq_32.booking__ds_partitioned__extract_quarter - , subq_32.booking__ds_partitioned__extract_month - , subq_32.booking__ds_partitioned__extract_day - , subq_32.booking__ds_partitioned__extract_dow - , subq_32.booking__ds_partitioned__extract_doy - , subq_32.booking__paid_at__day - , subq_32.booking__paid_at__week - , subq_32.booking__paid_at__month - , subq_32.booking__paid_at__quarter - , subq_32.booking__paid_at__year - , subq_32.booking__paid_at__extract_year - , subq_32.booking__paid_at__extract_quarter - , subq_32.booking__paid_at__extract_month - , subq_32.booking__paid_at__extract_day - , subq_32.booking__paid_at__extract_dow - , subq_32.booking__paid_at__extract_doy - , subq_32.metric_time__day - , subq_32.metric_time__week - , subq_32.metric_time__month - , subq_32.metric_time__quarter - , subq_32.metric_time__year - , subq_32.metric_time__extract_year - , subq_32.metric_time__extract_quarter - , subq_32.metric_time__extract_month - , subq_32.metric_time__extract_day - , subq_32.metric_time__extract_dow - , subq_32.metric_time__extract_doy - , subq_32.listing - , subq_32.guest - , subq_32.host - , subq_32.booking__listing - , subq_32.booking__guest - , subq_32.booking__host - , subq_32.is_instant - , subq_32.booking__is_instant - , subq_32.bookings - , subq_32.instant_bookings - , subq_32.booking_value - , subq_32.max_booking_value - , subq_32.min_booking_value - , subq_32.bookers - , subq_32.average_booking_value - , subq_32.referred_bookings - , subq_32.median_booking_value - , subq_32.booking_value_p99 - , subq_32.discrete_booking_value_p99 - , subq_32.approximate_continuous_booking_value_p99 - , subq_32.approximate_discrete_booking_value_p99 + subq_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.metric_time__day + , subq_20.metric_time__week + , subq_20.metric_time__month + , subq_20.metric_time__quarter + , subq_20.metric_time__year + , subq_20.metric_time__extract_year + , subq_20.metric_time__extract_quarter + , subq_20.metric_time__extract_month + , subq_20.metric_time__extract_day + , subq_20.metric_time__extract_dow + , subq_20.metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_31.ds__day - , subq_31.ds__week - , subq_31.ds__month - , subq_31.ds__quarter - , subq_31.ds__year - , subq_31.ds__extract_year - , subq_31.ds__extract_quarter - , subq_31.ds__extract_month - , subq_31.ds__extract_day - , subq_31.ds__extract_dow - , subq_31.ds__extract_doy - , subq_31.ds_partitioned__day - , subq_31.ds_partitioned__week - , subq_31.ds_partitioned__month - , subq_31.ds_partitioned__quarter - , subq_31.ds_partitioned__year - , subq_31.ds_partitioned__extract_year - , subq_31.ds_partitioned__extract_quarter - , subq_31.ds_partitioned__extract_month - , subq_31.ds_partitioned__extract_day - , subq_31.ds_partitioned__extract_dow - , subq_31.ds_partitioned__extract_doy - , subq_31.paid_at__day - , subq_31.paid_at__week - , subq_31.paid_at__month - , subq_31.paid_at__quarter - , subq_31.paid_at__year - , subq_31.paid_at__extract_year - , subq_31.paid_at__extract_quarter - , subq_31.paid_at__extract_month - , subq_31.paid_at__extract_day - , subq_31.paid_at__extract_dow - , subq_31.paid_at__extract_doy - , subq_31.booking__ds__day - , subq_31.booking__ds__week - , subq_31.booking__ds__month - , subq_31.booking__ds__quarter - , subq_31.booking__ds__year - , subq_31.booking__ds__extract_year - , subq_31.booking__ds__extract_quarter - , subq_31.booking__ds__extract_month - , subq_31.booking__ds__extract_day - , subq_31.booking__ds__extract_dow - , subq_31.booking__ds__extract_doy - , subq_31.booking__ds_partitioned__day - , subq_31.booking__ds_partitioned__week - , subq_31.booking__ds_partitioned__month - , subq_31.booking__ds_partitioned__quarter - , subq_31.booking__ds_partitioned__year - , subq_31.booking__ds_partitioned__extract_year - , subq_31.booking__ds_partitioned__extract_quarter - , subq_31.booking__ds_partitioned__extract_month - , subq_31.booking__ds_partitioned__extract_day - , subq_31.booking__ds_partitioned__extract_dow - , subq_31.booking__ds_partitioned__extract_doy - , subq_31.booking__paid_at__day - , subq_31.booking__paid_at__week - , subq_31.booking__paid_at__month - , subq_31.booking__paid_at__quarter - , subq_31.booking__paid_at__year - , subq_31.booking__paid_at__extract_year - , subq_31.booking__paid_at__extract_quarter - , subq_31.booking__paid_at__extract_month - , subq_31.booking__paid_at__extract_day - , subq_31.booking__paid_at__extract_dow - , subq_31.booking__paid_at__extract_doy - , subq_31.ds__day AS metric_time__day - , subq_31.ds__week AS metric_time__week - , subq_31.ds__month AS metric_time__month - , subq_31.ds__quarter AS metric_time__quarter - , subq_31.ds__year AS metric_time__year - , subq_31.ds__extract_year AS metric_time__extract_year - , subq_31.ds__extract_quarter AS metric_time__extract_quarter - , subq_31.ds__extract_month AS metric_time__extract_month - , subq_31.ds__extract_day AS metric_time__extract_day - , subq_31.ds__extract_dow AS metric_time__extract_dow - , subq_31.ds__extract_doy AS metric_time__extract_doy - , subq_31.listing - , subq_31.guest - , subq_31.host - , subq_31.booking__listing - , subq_31.booking__guest - , subq_31.booking__host - , subq_31.is_instant - , subq_31.booking__is_instant - , subq_31.bookings - , subq_31.instant_bookings - , subq_31.booking_value - , subq_31.max_booking_value - , subq_31.min_booking_value - , subq_31.bookers - , subq_31.average_booking_value - , subq_31.referred_bookings - , subq_31.median_booking_value - , subq_31.booking_value_p99 - , subq_31.discrete_booking_value_p99 - , subq_31.approximate_continuous_booking_value_p99 - , subq_31.approximate_discrete_booking_value_p99 + subq_19.ds__day + , subq_19.ds__week + , subq_19.ds__month + , subq_19.ds__quarter + , subq_19.ds__year + , subq_19.ds__extract_year + , subq_19.ds__extract_quarter + , subq_19.ds__extract_month + , subq_19.ds__extract_day + , subq_19.ds__extract_dow + , subq_19.ds__extract_doy + , subq_19.ds_partitioned__day + , subq_19.ds_partitioned__week + , subq_19.ds_partitioned__month + , subq_19.ds_partitioned__quarter + , subq_19.ds_partitioned__year + , subq_19.ds_partitioned__extract_year + , subq_19.ds_partitioned__extract_quarter + , subq_19.ds_partitioned__extract_month + , subq_19.ds_partitioned__extract_day + , subq_19.ds_partitioned__extract_dow + , subq_19.ds_partitioned__extract_doy + , subq_19.paid_at__day + , subq_19.paid_at__week + , subq_19.paid_at__month + , subq_19.paid_at__quarter + , subq_19.paid_at__year + , subq_19.paid_at__extract_year + , subq_19.paid_at__extract_quarter + , subq_19.paid_at__extract_month + , subq_19.paid_at__extract_day + , subq_19.paid_at__extract_dow + , subq_19.paid_at__extract_doy + , subq_19.booking__ds__day + , subq_19.booking__ds__week + , subq_19.booking__ds__month + , subq_19.booking__ds__quarter + , subq_19.booking__ds__year + , subq_19.booking__ds__extract_year + , subq_19.booking__ds__extract_quarter + , subq_19.booking__ds__extract_month + , subq_19.booking__ds__extract_day + , subq_19.booking__ds__extract_dow + , subq_19.booking__ds__extract_doy + , subq_19.booking__ds_partitioned__day + , subq_19.booking__ds_partitioned__week + , subq_19.booking__ds_partitioned__month + , subq_19.booking__ds_partitioned__quarter + , subq_19.booking__ds_partitioned__year + , subq_19.booking__ds_partitioned__extract_year + , subq_19.booking__ds_partitioned__extract_quarter + , subq_19.booking__ds_partitioned__extract_month + , subq_19.booking__ds_partitioned__extract_day + , subq_19.booking__ds_partitioned__extract_dow + , subq_19.booking__ds_partitioned__extract_doy + , subq_19.booking__paid_at__day + , subq_19.booking__paid_at__week + , subq_19.booking__paid_at__month + , subq_19.booking__paid_at__quarter + , subq_19.booking__paid_at__year + , subq_19.booking__paid_at__extract_year + , subq_19.booking__paid_at__extract_quarter + , subq_19.booking__paid_at__extract_month + , subq_19.booking__paid_at__extract_day + , subq_19.booking__paid_at__extract_dow + , subq_19.booking__paid_at__extract_doy + , subq_19.ds__day AS metric_time__day + , subq_19.ds__week AS metric_time__week + , subq_19.ds__month AS metric_time__month + , subq_19.ds__quarter AS metric_time__quarter + , subq_19.ds__year AS metric_time__year + , subq_19.ds__extract_year AS metric_time__extract_year + , subq_19.ds__extract_quarter AS metric_time__extract_quarter + , subq_19.ds__extract_month AS metric_time__extract_month + , subq_19.ds__extract_day AS metric_time__extract_day + , subq_19.ds__extract_dow AS metric_time__extract_dow + , subq_19.ds__extract_doy AS metric_time__extract_doy + , subq_19.listing + , subq_19.guest + , subq_19.host + , subq_19.booking__listing + , subq_19.booking__guest + , subq_19.booking__host + , subq_19.is_instant + , subq_19.booking__is_instant + , subq_19.bookings + , subq_19.instant_bookings + , subq_19.booking_value + , subq_19.max_booking_value + , subq_19.min_booking_value + , subq_19.bookers + , subq_19.average_booking_value + , subq_19.referred_bookings + , subq_19.median_booking_value + , subq_19.booking_value_p99 + , subq_19.discrete_booking_value_p99 + , subq_19.approximate_continuous_booking_value_p99 + , subq_19.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -825,86 +825,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_31 - ) subq_32 + ) subq_19 + ) subq_20 WHERE booking__is_instant - ) subq_33 - ) subq_34 + ) subq_21 + ) subq_22 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_36.listing - , subq_36.is_lux_latest + subq_24.listing + , subq_24.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_35.ds__day - , subq_35.ds__week - , subq_35.ds__month - , subq_35.ds__quarter - , subq_35.ds__year - , subq_35.ds__extract_year - , subq_35.ds__extract_quarter - , subq_35.ds__extract_month - , subq_35.ds__extract_day - , subq_35.ds__extract_dow - , subq_35.ds__extract_doy - , subq_35.created_at__day - , subq_35.created_at__week - , subq_35.created_at__month - , subq_35.created_at__quarter - , subq_35.created_at__year - , subq_35.created_at__extract_year - , subq_35.created_at__extract_quarter - , subq_35.created_at__extract_month - , subq_35.created_at__extract_day - , subq_35.created_at__extract_dow - , subq_35.created_at__extract_doy - , subq_35.listing__ds__day - , subq_35.listing__ds__week - , subq_35.listing__ds__month - , subq_35.listing__ds__quarter - , subq_35.listing__ds__year - , subq_35.listing__ds__extract_year - , subq_35.listing__ds__extract_quarter - , subq_35.listing__ds__extract_month - , subq_35.listing__ds__extract_day - , subq_35.listing__ds__extract_dow - , subq_35.listing__ds__extract_doy - , subq_35.listing__created_at__day - , subq_35.listing__created_at__week - , subq_35.listing__created_at__month - , subq_35.listing__created_at__quarter - , subq_35.listing__created_at__year - , subq_35.listing__created_at__extract_year - , subq_35.listing__created_at__extract_quarter - , subq_35.listing__created_at__extract_month - , subq_35.listing__created_at__extract_day - , subq_35.listing__created_at__extract_dow - , subq_35.listing__created_at__extract_doy - , subq_35.ds__day AS metric_time__day - , subq_35.ds__week AS metric_time__week - , subq_35.ds__month AS metric_time__month - , subq_35.ds__quarter AS metric_time__quarter - , subq_35.ds__year AS metric_time__year - , subq_35.ds__extract_year AS metric_time__extract_year - , subq_35.ds__extract_quarter AS metric_time__extract_quarter - , subq_35.ds__extract_month AS metric_time__extract_month - , subq_35.ds__extract_day AS metric_time__extract_day - , subq_35.ds__extract_dow AS metric_time__extract_dow - , subq_35.ds__extract_doy AS metric_time__extract_doy - , subq_35.listing - , subq_35.user - , subq_35.listing__user - , subq_35.country_latest - , subq_35.is_lux_latest - , subq_35.capacity_latest - , subq_35.listing__country_latest - , subq_35.listing__is_lux_latest - , subq_35.listing__capacity_latest - , subq_35.listings - , subq_35.largest_listing - , subq_35.smallest_listing + subq_23.ds__day + , subq_23.ds__week + , subq_23.ds__month + , subq_23.ds__quarter + , subq_23.ds__year + , subq_23.ds__extract_year + , subq_23.ds__extract_quarter + , subq_23.ds__extract_month + , subq_23.ds__extract_day + , subq_23.ds__extract_dow + , subq_23.ds__extract_doy + , subq_23.created_at__day + , subq_23.created_at__week + , subq_23.created_at__month + , subq_23.created_at__quarter + , subq_23.created_at__year + , subq_23.created_at__extract_year + , subq_23.created_at__extract_quarter + , subq_23.created_at__extract_month + , subq_23.created_at__extract_day + , subq_23.created_at__extract_dow + , subq_23.created_at__extract_doy + , subq_23.listing__ds__day + , subq_23.listing__ds__week + , subq_23.listing__ds__month + , subq_23.listing__ds__quarter + , subq_23.listing__ds__year + , subq_23.listing__ds__extract_year + , subq_23.listing__ds__extract_quarter + , subq_23.listing__ds__extract_month + , subq_23.listing__ds__extract_day + , subq_23.listing__ds__extract_dow + , subq_23.listing__ds__extract_doy + , subq_23.listing__created_at__day + , subq_23.listing__created_at__week + , subq_23.listing__created_at__month + , subq_23.listing__created_at__quarter + , subq_23.listing__created_at__year + , subq_23.listing__created_at__extract_year + , subq_23.listing__created_at__extract_quarter + , subq_23.listing__created_at__extract_month + , subq_23.listing__created_at__extract_day + , subq_23.listing__created_at__extract_dow + , subq_23.listing__created_at__extract_doy + , subq_23.ds__day AS metric_time__day + , subq_23.ds__week AS metric_time__week + , subq_23.ds__month AS metric_time__month + , subq_23.ds__quarter AS metric_time__quarter + , subq_23.ds__year AS metric_time__year + , subq_23.ds__extract_year AS metric_time__extract_year + , subq_23.ds__extract_quarter AS metric_time__extract_quarter + , subq_23.ds__extract_month AS metric_time__extract_month + , subq_23.ds__extract_day AS metric_time__extract_day + , subq_23.ds__extract_dow AS metric_time__extract_dow + , subq_23.ds__extract_doy AS metric_time__extract_doy + , subq_23.listing + , subq_23.user + , subq_23.listing__user + , subq_23.country_latest + , subq_23.is_lux_latest + , subq_23.capacity_latest + , subq_23.listing__country_latest + , subq_23.listing__is_lux_latest + , subq_23.listing__capacity_latest + , subq_23.listings + , subq_23.largest_listing + , subq_23.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -965,242 +965,242 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_35 - ) subq_36 - ) subq_37 + ) subq_23 + ) subq_24 + ) subq_25 ON - subq_34.listing = subq_37.listing - ) subq_38 - ) subq_39 + subq_22.listing = subq_25.listing + ) subq_26 + ) subq_27 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_40 - ) subq_41 - ) subq_42 - ) subq_43 + ) subq_28 + ) subq_29 + ) subq_30 + ) subq_31 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_50.booking_value + subq_38.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_49.booking_value) AS booking_value + SUM(subq_37.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_48.booking_value + subq_36.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_47.booking__is_instant - , subq_47.booking_value + subq_35.booking__is_instant + , subq_35.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_46.booking__is_instant - , subq_46.booking_value + subq_34.booking__is_instant + , subq_34.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_45.ds__day - , subq_45.ds__week - , subq_45.ds__month - , subq_45.ds__quarter - , subq_45.ds__year - , subq_45.ds__extract_year - , subq_45.ds__extract_quarter - , subq_45.ds__extract_month - , subq_45.ds__extract_day - , subq_45.ds__extract_dow - , subq_45.ds__extract_doy - , subq_45.ds_partitioned__day - , subq_45.ds_partitioned__week - , subq_45.ds_partitioned__month - , subq_45.ds_partitioned__quarter - , subq_45.ds_partitioned__year - , subq_45.ds_partitioned__extract_year - , subq_45.ds_partitioned__extract_quarter - , subq_45.ds_partitioned__extract_month - , subq_45.ds_partitioned__extract_day - , subq_45.ds_partitioned__extract_dow - , subq_45.ds_partitioned__extract_doy - , subq_45.paid_at__day - , subq_45.paid_at__week - , subq_45.paid_at__month - , subq_45.paid_at__quarter - , subq_45.paid_at__year - , subq_45.paid_at__extract_year - , subq_45.paid_at__extract_quarter - , subq_45.paid_at__extract_month - , subq_45.paid_at__extract_day - , subq_45.paid_at__extract_dow - , subq_45.paid_at__extract_doy - , subq_45.booking__ds__day - , subq_45.booking__ds__week - , subq_45.booking__ds__month - , subq_45.booking__ds__quarter - , subq_45.booking__ds__year - , subq_45.booking__ds__extract_year - , subq_45.booking__ds__extract_quarter - , subq_45.booking__ds__extract_month - , subq_45.booking__ds__extract_day - , subq_45.booking__ds__extract_dow - , subq_45.booking__ds__extract_doy - , subq_45.booking__ds_partitioned__day - , subq_45.booking__ds_partitioned__week - , subq_45.booking__ds_partitioned__month - , subq_45.booking__ds_partitioned__quarter - , subq_45.booking__ds_partitioned__year - , subq_45.booking__ds_partitioned__extract_year - , subq_45.booking__ds_partitioned__extract_quarter - , subq_45.booking__ds_partitioned__extract_month - , subq_45.booking__ds_partitioned__extract_day - , subq_45.booking__ds_partitioned__extract_dow - , subq_45.booking__ds_partitioned__extract_doy - , subq_45.booking__paid_at__day - , subq_45.booking__paid_at__week - , subq_45.booking__paid_at__month - , subq_45.booking__paid_at__quarter - , subq_45.booking__paid_at__year - , subq_45.booking__paid_at__extract_year - , subq_45.booking__paid_at__extract_quarter - , subq_45.booking__paid_at__extract_month - , subq_45.booking__paid_at__extract_day - , subq_45.booking__paid_at__extract_dow - , subq_45.booking__paid_at__extract_doy - , subq_45.metric_time__day - , subq_45.metric_time__week - , subq_45.metric_time__month - , subq_45.metric_time__quarter - , subq_45.metric_time__year - , subq_45.metric_time__extract_year - , subq_45.metric_time__extract_quarter - , subq_45.metric_time__extract_month - , subq_45.metric_time__extract_day - , subq_45.metric_time__extract_dow - , subq_45.metric_time__extract_doy - , subq_45.listing - , subq_45.guest - , subq_45.host - , subq_45.booking__listing - , subq_45.booking__guest - , subq_45.booking__host - , subq_45.is_instant - , subq_45.booking__is_instant - , subq_45.bookings - , subq_45.instant_bookings - , subq_45.booking_value - , subq_45.max_booking_value - , subq_45.min_booking_value - , subq_45.bookers - , subq_45.average_booking_value - , subq_45.referred_bookings - , subq_45.median_booking_value - , subq_45.booking_value_p99 - , subq_45.discrete_booking_value_p99 - , subq_45.approximate_continuous_booking_value_p99 - , subq_45.approximate_discrete_booking_value_p99 + subq_33.ds__day + , subq_33.ds__week + , subq_33.ds__month + , subq_33.ds__quarter + , subq_33.ds__year + , subq_33.ds__extract_year + , subq_33.ds__extract_quarter + , subq_33.ds__extract_month + , subq_33.ds__extract_day + , subq_33.ds__extract_dow + , subq_33.ds__extract_doy + , subq_33.ds_partitioned__day + , subq_33.ds_partitioned__week + , subq_33.ds_partitioned__month + , subq_33.ds_partitioned__quarter + , subq_33.ds_partitioned__year + , subq_33.ds_partitioned__extract_year + , subq_33.ds_partitioned__extract_quarter + , subq_33.ds_partitioned__extract_month + , subq_33.ds_partitioned__extract_day + , subq_33.ds_partitioned__extract_dow + , subq_33.ds_partitioned__extract_doy + , subq_33.paid_at__day + , subq_33.paid_at__week + , subq_33.paid_at__month + , subq_33.paid_at__quarter + , subq_33.paid_at__year + , subq_33.paid_at__extract_year + , subq_33.paid_at__extract_quarter + , subq_33.paid_at__extract_month + , subq_33.paid_at__extract_day + , subq_33.paid_at__extract_dow + , subq_33.paid_at__extract_doy + , subq_33.booking__ds__day + , subq_33.booking__ds__week + , subq_33.booking__ds__month + , subq_33.booking__ds__quarter + , subq_33.booking__ds__year + , subq_33.booking__ds__extract_year + , subq_33.booking__ds__extract_quarter + , subq_33.booking__ds__extract_month + , subq_33.booking__ds__extract_day + , subq_33.booking__ds__extract_dow + , subq_33.booking__ds__extract_doy + , subq_33.booking__ds_partitioned__day + , subq_33.booking__ds_partitioned__week + , subq_33.booking__ds_partitioned__month + , subq_33.booking__ds_partitioned__quarter + , subq_33.booking__ds_partitioned__year + , subq_33.booking__ds_partitioned__extract_year + , subq_33.booking__ds_partitioned__extract_quarter + , subq_33.booking__ds_partitioned__extract_month + , subq_33.booking__ds_partitioned__extract_day + , subq_33.booking__ds_partitioned__extract_dow + , subq_33.booking__ds_partitioned__extract_doy + , subq_33.booking__paid_at__day + , subq_33.booking__paid_at__week + , subq_33.booking__paid_at__month + , subq_33.booking__paid_at__quarter + , subq_33.booking__paid_at__year + , subq_33.booking__paid_at__extract_year + , subq_33.booking__paid_at__extract_quarter + , subq_33.booking__paid_at__extract_month + , subq_33.booking__paid_at__extract_day + , subq_33.booking__paid_at__extract_dow + , subq_33.booking__paid_at__extract_doy + , subq_33.metric_time__day + , subq_33.metric_time__week + , subq_33.metric_time__month + , subq_33.metric_time__quarter + , subq_33.metric_time__year + , subq_33.metric_time__extract_year + , subq_33.metric_time__extract_quarter + , subq_33.metric_time__extract_month + , subq_33.metric_time__extract_day + , subq_33.metric_time__extract_dow + , subq_33.metric_time__extract_doy + , subq_33.listing + , subq_33.guest + , subq_33.host + , subq_33.booking__listing + , subq_33.booking__guest + , subq_33.booking__host + , subq_33.is_instant + , subq_33.booking__is_instant + , subq_33.bookings + , subq_33.instant_bookings + , subq_33.booking_value + , subq_33.max_booking_value + , subq_33.min_booking_value + , subq_33.bookers + , subq_33.average_booking_value + , subq_33.referred_bookings + , subq_33.median_booking_value + , subq_33.booking_value_p99 + , subq_33.discrete_booking_value_p99 + , subq_33.approximate_continuous_booking_value_p99 + , subq_33.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_44.ds__day - , subq_44.ds__week - , subq_44.ds__month - , subq_44.ds__quarter - , subq_44.ds__year - , subq_44.ds__extract_year - , subq_44.ds__extract_quarter - , subq_44.ds__extract_month - , subq_44.ds__extract_day - , subq_44.ds__extract_dow - , subq_44.ds__extract_doy - , subq_44.ds_partitioned__day - , subq_44.ds_partitioned__week - , subq_44.ds_partitioned__month - , subq_44.ds_partitioned__quarter - , subq_44.ds_partitioned__year - , subq_44.ds_partitioned__extract_year - , subq_44.ds_partitioned__extract_quarter - , subq_44.ds_partitioned__extract_month - , subq_44.ds_partitioned__extract_day - , subq_44.ds_partitioned__extract_dow - , subq_44.ds_partitioned__extract_doy - , subq_44.paid_at__day - , subq_44.paid_at__week - , subq_44.paid_at__month - , subq_44.paid_at__quarter - , subq_44.paid_at__year - , subq_44.paid_at__extract_year - , subq_44.paid_at__extract_quarter - , subq_44.paid_at__extract_month - , subq_44.paid_at__extract_day - , subq_44.paid_at__extract_dow - , subq_44.paid_at__extract_doy - , subq_44.booking__ds__day - , subq_44.booking__ds__week - , subq_44.booking__ds__month - , subq_44.booking__ds__quarter - , subq_44.booking__ds__year - , subq_44.booking__ds__extract_year - , subq_44.booking__ds__extract_quarter - , subq_44.booking__ds__extract_month - , subq_44.booking__ds__extract_day - , subq_44.booking__ds__extract_dow - , subq_44.booking__ds__extract_doy - , subq_44.booking__ds_partitioned__day - , subq_44.booking__ds_partitioned__week - , subq_44.booking__ds_partitioned__month - , subq_44.booking__ds_partitioned__quarter - , subq_44.booking__ds_partitioned__year - , subq_44.booking__ds_partitioned__extract_year - , subq_44.booking__ds_partitioned__extract_quarter - , subq_44.booking__ds_partitioned__extract_month - , subq_44.booking__ds_partitioned__extract_day - , subq_44.booking__ds_partitioned__extract_dow - , subq_44.booking__ds_partitioned__extract_doy - , subq_44.booking__paid_at__day - , subq_44.booking__paid_at__week - , subq_44.booking__paid_at__month - , subq_44.booking__paid_at__quarter - , subq_44.booking__paid_at__year - , subq_44.booking__paid_at__extract_year - , subq_44.booking__paid_at__extract_quarter - , subq_44.booking__paid_at__extract_month - , subq_44.booking__paid_at__extract_day - , subq_44.booking__paid_at__extract_dow - , subq_44.booking__paid_at__extract_doy - , subq_44.ds__day AS metric_time__day - , subq_44.ds__week AS metric_time__week - , subq_44.ds__month AS metric_time__month - , subq_44.ds__quarter AS metric_time__quarter - , subq_44.ds__year AS metric_time__year - , subq_44.ds__extract_year AS metric_time__extract_year - , subq_44.ds__extract_quarter AS metric_time__extract_quarter - , subq_44.ds__extract_month AS metric_time__extract_month - , subq_44.ds__extract_day AS metric_time__extract_day - , subq_44.ds__extract_dow AS metric_time__extract_dow - , subq_44.ds__extract_doy AS metric_time__extract_doy - , subq_44.listing - , subq_44.guest - , subq_44.host - , subq_44.booking__listing - , subq_44.booking__guest - , subq_44.booking__host - , subq_44.is_instant - , subq_44.booking__is_instant - , subq_44.bookings - , subq_44.instant_bookings - , subq_44.booking_value - , subq_44.max_booking_value - , subq_44.min_booking_value - , subq_44.bookers - , subq_44.average_booking_value - , subq_44.referred_bookings - , subq_44.median_booking_value - , subq_44.booking_value_p99 - , subq_44.discrete_booking_value_p99 - , subq_44.approximate_continuous_booking_value_p99 - , subq_44.approximate_discrete_booking_value_p99 + subq_32.ds__day + , subq_32.ds__week + , subq_32.ds__month + , subq_32.ds__quarter + , subq_32.ds__year + , subq_32.ds__extract_year + , subq_32.ds__extract_quarter + , subq_32.ds__extract_month + , subq_32.ds__extract_day + , subq_32.ds__extract_dow + , subq_32.ds__extract_doy + , subq_32.ds_partitioned__day + , subq_32.ds_partitioned__week + , subq_32.ds_partitioned__month + , subq_32.ds_partitioned__quarter + , subq_32.ds_partitioned__year + , subq_32.ds_partitioned__extract_year + , subq_32.ds_partitioned__extract_quarter + , subq_32.ds_partitioned__extract_month + , subq_32.ds_partitioned__extract_day + , subq_32.ds_partitioned__extract_dow + , subq_32.ds_partitioned__extract_doy + , subq_32.paid_at__day + , subq_32.paid_at__week + , subq_32.paid_at__month + , subq_32.paid_at__quarter + , subq_32.paid_at__year + , subq_32.paid_at__extract_year + , subq_32.paid_at__extract_quarter + , subq_32.paid_at__extract_month + , subq_32.paid_at__extract_day + , subq_32.paid_at__extract_dow + , subq_32.paid_at__extract_doy + , subq_32.booking__ds__day + , subq_32.booking__ds__week + , subq_32.booking__ds__month + , subq_32.booking__ds__quarter + , subq_32.booking__ds__year + , subq_32.booking__ds__extract_year + , subq_32.booking__ds__extract_quarter + , subq_32.booking__ds__extract_month + , subq_32.booking__ds__extract_day + , subq_32.booking__ds__extract_dow + , subq_32.booking__ds__extract_doy + , subq_32.booking__ds_partitioned__day + , subq_32.booking__ds_partitioned__week + , subq_32.booking__ds_partitioned__month + , subq_32.booking__ds_partitioned__quarter + , subq_32.booking__ds_partitioned__year + , subq_32.booking__ds_partitioned__extract_year + , subq_32.booking__ds_partitioned__extract_quarter + , subq_32.booking__ds_partitioned__extract_month + , subq_32.booking__ds_partitioned__extract_day + , subq_32.booking__ds_partitioned__extract_dow + , subq_32.booking__ds_partitioned__extract_doy + , subq_32.booking__paid_at__day + , subq_32.booking__paid_at__week + , subq_32.booking__paid_at__month + , subq_32.booking__paid_at__quarter + , subq_32.booking__paid_at__year + , subq_32.booking__paid_at__extract_year + , subq_32.booking__paid_at__extract_quarter + , subq_32.booking__paid_at__extract_month + , subq_32.booking__paid_at__extract_day + , subq_32.booking__paid_at__extract_dow + , subq_32.booking__paid_at__extract_doy + , subq_32.ds__day AS metric_time__day + , subq_32.ds__week AS metric_time__week + , subq_32.ds__month AS metric_time__month + , subq_32.ds__quarter AS metric_time__quarter + , subq_32.ds__year AS metric_time__year + , subq_32.ds__extract_year AS metric_time__extract_year + , subq_32.ds__extract_quarter AS metric_time__extract_quarter + , subq_32.ds__extract_month AS metric_time__extract_month + , subq_32.ds__extract_day AS metric_time__extract_day + , subq_32.ds__extract_dow AS metric_time__extract_dow + , subq_32.ds__extract_doy AS metric_time__extract_doy + , subq_32.listing + , subq_32.guest + , subq_32.host + , subq_32.booking__listing + , subq_32.booking__guest + , subq_32.booking__host + , subq_32.is_instant + , subq_32.booking__is_instant + , subq_32.bookings + , subq_32.instant_bookings + , subq_32.booking_value + , subq_32.max_booking_value + , subq_32.min_booking_value + , subq_32.bookers + , subq_32.average_booking_value + , subq_32.referred_bookings + , subq_32.median_booking_value + , subq_32.booking_value_p99 + , subq_32.discrete_booking_value_p99 + , subq_32.approximate_continuous_booking_value_p99 + , subq_32.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -1293,15 +1293,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_44 - ) subq_45 + ) subq_32 + ) subq_33 WHERE booking__is_instant - ) subq_46 - ) subq_47 + ) subq_34 + ) subq_35 WHERE booking__is_instant - ) subq_48 - ) subq_49 - ) subq_50 - ) subq_51 - ) subq_52 -) subq_53 + ) subq_36 + ) subq_37 + ) subq_38 + ) subq_39 + ) subq_40 +) subq_41 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/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 a0fdc735bd..60a09b752b 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_66.average_booking_value) AS average_booking_value - , MAX(subq_79.bookings) AS bookings - , MAX(subq_87.booking_value) AS booking_value + MAX(subq_54.average_booking_value) AS average_booking_value + , MAX(subq_67.bookings) AS bookings + , MAX(subq_75.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value',] @@ -22,9 +22,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_57.booking__is_instant AS booking__is_instant + subq_45.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_57.average_booking_value AS average_booking_value + , subq_45.average_booking_value AS average_booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] @@ -40,16 +40,16 @@ FROM ( , is_instant AS booking__is_instant , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_55 + ) subq_43 WHERE booking__is_instant - ) subq_57 + ) subq_45 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_57.listing = listings_latest_src_28000.listing_id - ) subq_62 + subq_45.listing = listings_latest_src_28000.listing_id + ) subq_50 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_66 + ) subq_54 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings',] @@ -61,9 +61,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_70.booking__is_instant AS booking__is_instant + subq_58.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_70.bookings AS bookings + , subq_58.bookings AS bookings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] @@ -79,16 +79,16 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_68 + ) subq_56 WHERE booking__is_instant - ) subq_70 + ) subq_58 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_70.listing = listings_latest_src_28000.listing_id - ) subq_75 + subq_58.listing = listings_latest_src_28000.listing_id + ) subq_63 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_79 + ) subq_67 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -109,10 +109,10 @@ FROM ( is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_81 + ) subq_69 WHERE booking__is_instant - ) subq_83 + ) subq_71 WHERE booking__is_instant - ) subq_87 - ) subq_88 -) subq_89 + ) subq_75 + ) subq_76 +) subq_77 diff --git a/tests_metricflow/snapshots/test_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 facafc599f..9654a4d454 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_30.average_booking_value) AS average_booking_value - , MAX(subq_43.bookings) AS bookings - , MAX(subq_51.booking_value) AS booking_value + MAX(subq_18.average_booking_value) AS average_booking_value + , MAX(subq_31.bookings) AS bookings + , MAX(subq_39.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_29.average_booking_value + subq_17.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_28.average_booking_value) AS average_booking_value + AVG(subq_16.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_27.average_booking_value + subq_15.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.listing__is_lux_latest - , subq_26.average_booking_value + subq_14.booking__is_instant + , subq_14.listing__is_lux_latest + , subq_14.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_25.booking__is_instant - , subq_25.listing__is_lux_latest - , subq_25.average_booking_value + subq_13.booking__is_instant + , subq_13.listing__is_lux_latest + , subq_13.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_21.listing AS listing - , subq_21.booking__is_instant AS booking__is_instant - , subq_24.is_lux_latest AS listing__is_lux_latest - , subq_21.average_booking_value AS average_booking_value + subq_9.listing AS listing + , subq_9.booking__is_instant AS booking__is_instant + , subq_12.is_lux_latest AS listing__is_lux_latest + , subq_9.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_20.listing - , subq_20.booking__is_instant - , subq_20.average_booking_value + subq_8.listing + , subq_8.booking__is_instant + , subq_8.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_19.ds__day - , subq_19.ds__week - , subq_19.ds__month - , subq_19.ds__quarter - , subq_19.ds__year - , subq_19.ds__extract_year - , subq_19.ds__extract_quarter - , subq_19.ds__extract_month - , subq_19.ds__extract_day - , subq_19.ds__extract_dow - , subq_19.ds__extract_doy - , subq_19.ds_partitioned__day - , subq_19.ds_partitioned__week - , subq_19.ds_partitioned__month - , subq_19.ds_partitioned__quarter - , subq_19.ds_partitioned__year - , subq_19.ds_partitioned__extract_year - , subq_19.ds_partitioned__extract_quarter - , subq_19.ds_partitioned__extract_month - , subq_19.ds_partitioned__extract_day - , subq_19.ds_partitioned__extract_dow - , subq_19.ds_partitioned__extract_doy - , subq_19.paid_at__day - , subq_19.paid_at__week - , subq_19.paid_at__month - , subq_19.paid_at__quarter - , subq_19.paid_at__year - , subq_19.paid_at__extract_year - , subq_19.paid_at__extract_quarter - , subq_19.paid_at__extract_month - , subq_19.paid_at__extract_day - , subq_19.paid_at__extract_dow - , subq_19.paid_at__extract_doy - , subq_19.booking__ds__day - , subq_19.booking__ds__week - , subq_19.booking__ds__month - , subq_19.booking__ds__quarter - , subq_19.booking__ds__year - , subq_19.booking__ds__extract_year - , subq_19.booking__ds__extract_quarter - , subq_19.booking__ds__extract_month - , subq_19.booking__ds__extract_day - , subq_19.booking__ds__extract_dow - , subq_19.booking__ds__extract_doy - , subq_19.booking__ds_partitioned__day - , subq_19.booking__ds_partitioned__week - , subq_19.booking__ds_partitioned__month - , subq_19.booking__ds_partitioned__quarter - , subq_19.booking__ds_partitioned__year - , subq_19.booking__ds_partitioned__extract_year - , subq_19.booking__ds_partitioned__extract_quarter - , subq_19.booking__ds_partitioned__extract_month - , subq_19.booking__ds_partitioned__extract_day - , subq_19.booking__ds_partitioned__extract_dow - , subq_19.booking__ds_partitioned__extract_doy - , subq_19.booking__paid_at__day - , subq_19.booking__paid_at__week - , subq_19.booking__paid_at__month - , subq_19.booking__paid_at__quarter - , subq_19.booking__paid_at__year - , subq_19.booking__paid_at__extract_year - , subq_19.booking__paid_at__extract_quarter - , subq_19.booking__paid_at__extract_month - , subq_19.booking__paid_at__extract_day - , subq_19.booking__paid_at__extract_dow - , subq_19.booking__paid_at__extract_doy - , subq_19.metric_time__day - , subq_19.metric_time__week - , subq_19.metric_time__month - , subq_19.metric_time__quarter - , subq_19.metric_time__year - , subq_19.metric_time__extract_year - , subq_19.metric_time__extract_quarter - , subq_19.metric_time__extract_month - , subq_19.metric_time__extract_day - , subq_19.metric_time__extract_dow - , subq_19.metric_time__extract_doy - , subq_19.listing - , subq_19.guest - , subq_19.host - , subq_19.booking__listing - , subq_19.booking__guest - , subq_19.booking__host - , subq_19.is_instant - , subq_19.booking__is_instant - , subq_19.bookings - , subq_19.instant_bookings - , subq_19.booking_value - , subq_19.max_booking_value - , subq_19.min_booking_value - , subq_19.bookers - , subq_19.average_booking_value - , subq_19.referred_bookings - , subq_19.median_booking_value - , subq_19.booking_value_p99 - , subq_19.discrete_booking_value_p99 - , subq_19.approximate_continuous_booking_value_p99 - , subq_19.approximate_discrete_booking_value_p99 + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.ds_partitioned__day + , subq_7.ds_partitioned__week + , subq_7.ds_partitioned__month + , subq_7.ds_partitioned__quarter + , subq_7.ds_partitioned__year + , subq_7.ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy + , subq_7.paid_at__day + , subq_7.paid_at__week + , subq_7.paid_at__month + , subq_7.paid_at__quarter + , subq_7.paid_at__year + , subq_7.paid_at__extract_year + , subq_7.paid_at__extract_quarter + , subq_7.paid_at__extract_month + , subq_7.paid_at__extract_day + , subq_7.paid_at__extract_dow + , subq_7.paid_at__extract_doy + , subq_7.booking__ds__day + , subq_7.booking__ds__week + , subq_7.booking__ds__month + , subq_7.booking__ds__quarter + , subq_7.booking__ds__year + , subq_7.booking__ds__extract_year + , subq_7.booking__ds__extract_quarter + , subq_7.booking__ds__extract_month + , subq_7.booking__ds__extract_day + , subq_7.booking__ds__extract_dow + , subq_7.booking__ds__extract_doy + , subq_7.booking__ds_partitioned__day + , subq_7.booking__ds_partitioned__week + , subq_7.booking__ds_partitioned__month + , subq_7.booking__ds_partitioned__quarter + , subq_7.booking__ds_partitioned__year + , subq_7.booking__ds_partitioned__extract_year + , subq_7.booking__ds_partitioned__extract_quarter + , subq_7.booking__ds_partitioned__extract_month + , subq_7.booking__ds_partitioned__extract_day + , subq_7.booking__ds_partitioned__extract_dow + , subq_7.booking__ds_partitioned__extract_doy + , subq_7.booking__paid_at__day + , subq_7.booking__paid_at__week + , subq_7.booking__paid_at__month + , subq_7.booking__paid_at__quarter + , subq_7.booking__paid_at__year + , subq_7.booking__paid_at__extract_year + , subq_7.booking__paid_at__extract_quarter + , subq_7.booking__paid_at__extract_month + , subq_7.booking__paid_at__extract_day + , subq_7.booking__paid_at__extract_dow + , subq_7.booking__paid_at__extract_doy + , subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.metric_time__month + , subq_7.metric_time__quarter + , subq_7.metric_time__year + , subq_7.metric_time__extract_year + , subq_7.metric_time__extract_quarter + , subq_7.metric_time__extract_month + , subq_7.metric_time__extract_day + , subq_7.metric_time__extract_dow + , subq_7.metric_time__extract_doy + , subq_7.listing + , subq_7.guest + , subq_7.host + , subq_7.booking__listing + , subq_7.booking__guest + , subq_7.booking__host + , subq_7.is_instant + , subq_7.booking__is_instant + , subq_7.bookings + , subq_7.instant_bookings + , subq_7.booking_value + , subq_7.max_booking_value + , subq_7.min_booking_value + , subq_7.bookers + , subq_7.average_booking_value + , subq_7.referred_bookings + , subq_7.median_booking_value + , subq_7.booking_value_p99 + , subq_7.discrete_booking_value_p99 + , subq_7.approximate_continuous_booking_value_p99 + , subq_7.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.ds_partitioned__day - , subq_18.ds_partitioned__week - , subq_18.ds_partitioned__month - , subq_18.ds_partitioned__quarter - , subq_18.ds_partitioned__year - , subq_18.ds_partitioned__extract_year - , subq_18.ds_partitioned__extract_quarter - , subq_18.ds_partitioned__extract_month - , subq_18.ds_partitioned__extract_day - , subq_18.ds_partitioned__extract_dow - , subq_18.ds_partitioned__extract_doy - , subq_18.paid_at__day - , subq_18.paid_at__week - , subq_18.paid_at__month - , subq_18.paid_at__quarter - , subq_18.paid_at__year - , subq_18.paid_at__extract_year - , subq_18.paid_at__extract_quarter - , subq_18.paid_at__extract_month - , subq_18.paid_at__extract_day - , subq_18.paid_at__extract_dow - , subq_18.paid_at__extract_doy - , subq_18.booking__ds__day - , subq_18.booking__ds__week - , subq_18.booking__ds__month - , subq_18.booking__ds__quarter - , subq_18.booking__ds__year - , subq_18.booking__ds__extract_year - , subq_18.booking__ds__extract_quarter - , subq_18.booking__ds__extract_month - , subq_18.booking__ds__extract_day - , subq_18.booking__ds__extract_dow - , subq_18.booking__ds__extract_doy - , subq_18.booking__ds_partitioned__day - , subq_18.booking__ds_partitioned__week - , subq_18.booking__ds_partitioned__month - , subq_18.booking__ds_partitioned__quarter - , subq_18.booking__ds_partitioned__year - , subq_18.booking__ds_partitioned__extract_year - , subq_18.booking__ds_partitioned__extract_quarter - , subq_18.booking__ds_partitioned__extract_month - , subq_18.booking__ds_partitioned__extract_day - , subq_18.booking__ds_partitioned__extract_dow - , subq_18.booking__ds_partitioned__extract_doy - , subq_18.booking__paid_at__day - , subq_18.booking__paid_at__week - , subq_18.booking__paid_at__month - , subq_18.booking__paid_at__quarter - , subq_18.booking__paid_at__year - , subq_18.booking__paid_at__extract_year - , subq_18.booking__paid_at__extract_quarter - , subq_18.booking__paid_at__extract_month - , subq_18.booking__paid_at__extract_day - , subq_18.booking__paid_at__extract_dow - , subq_18.booking__paid_at__extract_doy - , subq_18.ds__day AS metric_time__day - , subq_18.ds__week AS metric_time__week - , subq_18.ds__month AS metric_time__month - , subq_18.ds__quarter AS metric_time__quarter - , subq_18.ds__year AS metric_time__year - , subq_18.ds__extract_year AS metric_time__extract_year - , subq_18.ds__extract_quarter AS metric_time__extract_quarter - , subq_18.ds__extract_month AS metric_time__extract_month - , subq_18.ds__extract_day AS metric_time__extract_day - , subq_18.ds__extract_dow AS metric_time__extract_dow - , subq_18.ds__extract_doy AS metric_time__extract_doy - , subq_18.listing - , subq_18.guest - , subq_18.host - , subq_18.booking__listing - , subq_18.booking__guest - , subq_18.booking__host - , subq_18.is_instant - , subq_18.booking__is_instant - , subq_18.bookings - , subq_18.instant_bookings - , subq_18.booking_value - , subq_18.max_booking_value - , subq_18.min_booking_value - , subq_18.bookers - , subq_18.average_booking_value - , subq_18.referred_bookings - , subq_18.median_booking_value - , subq_18.booking_value_p99 - , subq_18.discrete_booking_value_p99 - , subq_18.approximate_continuous_booking_value_p99 - , subq_18.approximate_discrete_booking_value_p99 + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -342,86 +342,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_18 - ) subq_19 + ) subq_6 + ) subq_7 WHERE booking__is_instant - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_23.listing - , subq_23.is_lux_latest + subq_11.listing + , subq_11.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_22.ds__day - , subq_22.ds__week - , subq_22.ds__month - , subq_22.ds__quarter - , subq_22.ds__year - , subq_22.ds__extract_year - , subq_22.ds__extract_quarter - , subq_22.ds__extract_month - , subq_22.ds__extract_day - , subq_22.ds__extract_dow - , subq_22.ds__extract_doy - , subq_22.created_at__day - , subq_22.created_at__week - , subq_22.created_at__month - , subq_22.created_at__quarter - , subq_22.created_at__year - , subq_22.created_at__extract_year - , subq_22.created_at__extract_quarter - , subq_22.created_at__extract_month - , subq_22.created_at__extract_day - , subq_22.created_at__extract_dow - , subq_22.created_at__extract_doy - , subq_22.listing__ds__day - , subq_22.listing__ds__week - , subq_22.listing__ds__month - , subq_22.listing__ds__quarter - , subq_22.listing__ds__year - , subq_22.listing__ds__extract_year - , subq_22.listing__ds__extract_quarter - , subq_22.listing__ds__extract_month - , subq_22.listing__ds__extract_day - , subq_22.listing__ds__extract_dow - , subq_22.listing__ds__extract_doy - , subq_22.listing__created_at__day - , subq_22.listing__created_at__week - , subq_22.listing__created_at__month - , subq_22.listing__created_at__quarter - , subq_22.listing__created_at__year - , subq_22.listing__created_at__extract_year - , subq_22.listing__created_at__extract_quarter - , subq_22.listing__created_at__extract_month - , subq_22.listing__created_at__extract_day - , subq_22.listing__created_at__extract_dow - , subq_22.listing__created_at__extract_doy - , subq_22.ds__day AS metric_time__day - , subq_22.ds__week AS metric_time__week - , subq_22.ds__month AS metric_time__month - , subq_22.ds__quarter AS metric_time__quarter - , subq_22.ds__year AS metric_time__year - , subq_22.ds__extract_year AS metric_time__extract_year - , subq_22.ds__extract_quarter AS metric_time__extract_quarter - , subq_22.ds__extract_month AS metric_time__extract_month - , subq_22.ds__extract_day AS metric_time__extract_day - , subq_22.ds__extract_dow AS metric_time__extract_dow - , subq_22.ds__extract_doy AS metric_time__extract_doy - , subq_22.listing - , subq_22.user - , subq_22.listing__user - , subq_22.country_latest - , subq_22.is_lux_latest - , subq_22.capacity_latest - , subq_22.listing__country_latest - , subq_22.listing__is_lux_latest - , subq_22.listing__capacity_latest - , subq_22.listings - , subq_22.largest_listing - , subq_22.smallest_listing + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.created_at__day + , subq_10.created_at__week + , subq_10.created_at__month + , subq_10.created_at__quarter + , subq_10.created_at__year + , subq_10.created_at__extract_year + , subq_10.created_at__extract_quarter + , subq_10.created_at__extract_month + , subq_10.created_at__extract_day + , subq_10.created_at__extract_dow + , subq_10.created_at__extract_doy + , subq_10.listing__ds__day + , subq_10.listing__ds__week + , subq_10.listing__ds__month + , subq_10.listing__ds__quarter + , subq_10.listing__ds__year + , subq_10.listing__ds__extract_year + , subq_10.listing__ds__extract_quarter + , subq_10.listing__ds__extract_month + , subq_10.listing__ds__extract_day + , subq_10.listing__ds__extract_dow + , subq_10.listing__ds__extract_doy + , subq_10.listing__created_at__day + , subq_10.listing__created_at__week + , subq_10.listing__created_at__month + , subq_10.listing__created_at__quarter + , subq_10.listing__created_at__year + , subq_10.listing__created_at__extract_year + , subq_10.listing__created_at__extract_quarter + , subq_10.listing__created_at__extract_month + , subq_10.listing__created_at__extract_day + , subq_10.listing__created_at__extract_dow + , subq_10.listing__created_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.user + , subq_10.listing__user + , subq_10.country_latest + , subq_10.is_lux_latest + , subq_10.capacity_latest + , subq_10.listing__country_latest + , subq_10.listing__is_lux_latest + , subq_10.listing__capacity_latest + , subq_10.listings + , subq_10.largest_listing + , subq_10.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -482,257 +482,257 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 - ) subq_23 - ) subq_24 + ) subq_10 + ) subq_11 + ) subq_12 ON - subq_21.listing = subq_24.listing - ) subq_25 - ) subq_26 + subq_9.listing = subq_12.listing + ) subq_13 + ) subq_14 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 + ) subq_15 + ) subq_16 + ) subq_17 + ) subq_18 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_42.bookings + subq_30.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_41.bookings) AS bookings + SUM(subq_29.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_40.bookings + subq_28.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_39.booking__is_instant - , subq_39.listing__is_lux_latest - , subq_39.bookings + subq_27.booking__is_instant + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_38.booking__is_instant - , subq_38.listing__is_lux_latest - , subq_38.bookings + subq_26.booking__is_instant + , subq_26.listing__is_lux_latest + , subq_26.bookings FROM ( -- Join Standard Outputs SELECT - subq_34.listing AS listing - , subq_34.booking__is_instant AS booking__is_instant - , subq_37.is_lux_latest AS listing__is_lux_latest - , subq_34.bookings AS bookings + subq_22.listing AS listing + , subq_22.booking__is_instant AS booking__is_instant + , subq_25.is_lux_latest AS listing__is_lux_latest + , subq_22.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_33.listing - , subq_33.booking__is_instant - , subq_33.bookings + subq_21.listing + , subq_21.booking__is_instant + , subq_21.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_32.ds__day - , subq_32.ds__week - , subq_32.ds__month - , subq_32.ds__quarter - , subq_32.ds__year - , subq_32.ds__extract_year - , subq_32.ds__extract_quarter - , subq_32.ds__extract_month - , subq_32.ds__extract_day - , subq_32.ds__extract_dow - , subq_32.ds__extract_doy - , subq_32.ds_partitioned__day - , subq_32.ds_partitioned__week - , subq_32.ds_partitioned__month - , subq_32.ds_partitioned__quarter - , subq_32.ds_partitioned__year - , subq_32.ds_partitioned__extract_year - , subq_32.ds_partitioned__extract_quarter - , subq_32.ds_partitioned__extract_month - , subq_32.ds_partitioned__extract_day - , subq_32.ds_partitioned__extract_dow - , subq_32.ds_partitioned__extract_doy - , subq_32.paid_at__day - , subq_32.paid_at__week - , subq_32.paid_at__month - , subq_32.paid_at__quarter - , subq_32.paid_at__year - , subq_32.paid_at__extract_year - , subq_32.paid_at__extract_quarter - , subq_32.paid_at__extract_month - , subq_32.paid_at__extract_day - , subq_32.paid_at__extract_dow - , subq_32.paid_at__extract_doy - , subq_32.booking__ds__day - , subq_32.booking__ds__week - , subq_32.booking__ds__month - , subq_32.booking__ds__quarter - , subq_32.booking__ds__year - , subq_32.booking__ds__extract_year - , subq_32.booking__ds__extract_quarter - , subq_32.booking__ds__extract_month - , subq_32.booking__ds__extract_day - , subq_32.booking__ds__extract_dow - , subq_32.booking__ds__extract_doy - , subq_32.booking__ds_partitioned__day - , subq_32.booking__ds_partitioned__week - , subq_32.booking__ds_partitioned__month - , subq_32.booking__ds_partitioned__quarter - , subq_32.booking__ds_partitioned__year - , subq_32.booking__ds_partitioned__extract_year - , subq_32.booking__ds_partitioned__extract_quarter - , subq_32.booking__ds_partitioned__extract_month - , subq_32.booking__ds_partitioned__extract_day - , subq_32.booking__ds_partitioned__extract_dow - , subq_32.booking__ds_partitioned__extract_doy - , subq_32.booking__paid_at__day - , subq_32.booking__paid_at__week - , subq_32.booking__paid_at__month - , subq_32.booking__paid_at__quarter - , subq_32.booking__paid_at__year - , subq_32.booking__paid_at__extract_year - , subq_32.booking__paid_at__extract_quarter - , subq_32.booking__paid_at__extract_month - , subq_32.booking__paid_at__extract_day - , subq_32.booking__paid_at__extract_dow - , subq_32.booking__paid_at__extract_doy - , subq_32.metric_time__day - , subq_32.metric_time__week - , subq_32.metric_time__month - , subq_32.metric_time__quarter - , subq_32.metric_time__year - , subq_32.metric_time__extract_year - , subq_32.metric_time__extract_quarter - , subq_32.metric_time__extract_month - , subq_32.metric_time__extract_day - , subq_32.metric_time__extract_dow - , subq_32.metric_time__extract_doy - , subq_32.listing - , subq_32.guest - , subq_32.host - , subq_32.booking__listing - , subq_32.booking__guest - , subq_32.booking__host - , subq_32.is_instant - , subq_32.booking__is_instant - , subq_32.bookings - , subq_32.instant_bookings - , subq_32.booking_value - , subq_32.max_booking_value - , subq_32.min_booking_value - , subq_32.bookers - , subq_32.average_booking_value - , subq_32.referred_bookings - , subq_32.median_booking_value - , subq_32.booking_value_p99 - , subq_32.discrete_booking_value_p99 - , subq_32.approximate_continuous_booking_value_p99 - , subq_32.approximate_discrete_booking_value_p99 + subq_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.metric_time__day + , subq_20.metric_time__week + , subq_20.metric_time__month + , subq_20.metric_time__quarter + , subq_20.metric_time__year + , subq_20.metric_time__extract_year + , subq_20.metric_time__extract_quarter + , subq_20.metric_time__extract_month + , subq_20.metric_time__extract_day + , subq_20.metric_time__extract_dow + , subq_20.metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_31.ds__day - , subq_31.ds__week - , subq_31.ds__month - , subq_31.ds__quarter - , subq_31.ds__year - , subq_31.ds__extract_year - , subq_31.ds__extract_quarter - , subq_31.ds__extract_month - , subq_31.ds__extract_day - , subq_31.ds__extract_dow - , subq_31.ds__extract_doy - , subq_31.ds_partitioned__day - , subq_31.ds_partitioned__week - , subq_31.ds_partitioned__month - , subq_31.ds_partitioned__quarter - , subq_31.ds_partitioned__year - , subq_31.ds_partitioned__extract_year - , subq_31.ds_partitioned__extract_quarter - , subq_31.ds_partitioned__extract_month - , subq_31.ds_partitioned__extract_day - , subq_31.ds_partitioned__extract_dow - , subq_31.ds_partitioned__extract_doy - , subq_31.paid_at__day - , subq_31.paid_at__week - , subq_31.paid_at__month - , subq_31.paid_at__quarter - , subq_31.paid_at__year - , subq_31.paid_at__extract_year - , subq_31.paid_at__extract_quarter - , subq_31.paid_at__extract_month - , subq_31.paid_at__extract_day - , subq_31.paid_at__extract_dow - , subq_31.paid_at__extract_doy - , subq_31.booking__ds__day - , subq_31.booking__ds__week - , subq_31.booking__ds__month - , subq_31.booking__ds__quarter - , subq_31.booking__ds__year - , subq_31.booking__ds__extract_year - , subq_31.booking__ds__extract_quarter - , subq_31.booking__ds__extract_month - , subq_31.booking__ds__extract_day - , subq_31.booking__ds__extract_dow - , subq_31.booking__ds__extract_doy - , subq_31.booking__ds_partitioned__day - , subq_31.booking__ds_partitioned__week - , subq_31.booking__ds_partitioned__month - , subq_31.booking__ds_partitioned__quarter - , subq_31.booking__ds_partitioned__year - , subq_31.booking__ds_partitioned__extract_year - , subq_31.booking__ds_partitioned__extract_quarter - , subq_31.booking__ds_partitioned__extract_month - , subq_31.booking__ds_partitioned__extract_day - , subq_31.booking__ds_partitioned__extract_dow - , subq_31.booking__ds_partitioned__extract_doy - , subq_31.booking__paid_at__day - , subq_31.booking__paid_at__week - , subq_31.booking__paid_at__month - , subq_31.booking__paid_at__quarter - , subq_31.booking__paid_at__year - , subq_31.booking__paid_at__extract_year - , subq_31.booking__paid_at__extract_quarter - , subq_31.booking__paid_at__extract_month - , subq_31.booking__paid_at__extract_day - , subq_31.booking__paid_at__extract_dow - , subq_31.booking__paid_at__extract_doy - , subq_31.ds__day AS metric_time__day - , subq_31.ds__week AS metric_time__week - , subq_31.ds__month AS metric_time__month - , subq_31.ds__quarter AS metric_time__quarter - , subq_31.ds__year AS metric_time__year - , subq_31.ds__extract_year AS metric_time__extract_year - , subq_31.ds__extract_quarter AS metric_time__extract_quarter - , subq_31.ds__extract_month AS metric_time__extract_month - , subq_31.ds__extract_day AS metric_time__extract_day - , subq_31.ds__extract_dow AS metric_time__extract_dow - , subq_31.ds__extract_doy AS metric_time__extract_doy - , subq_31.listing - , subq_31.guest - , subq_31.host - , subq_31.booking__listing - , subq_31.booking__guest - , subq_31.booking__host - , subq_31.is_instant - , subq_31.booking__is_instant - , subq_31.bookings - , subq_31.instant_bookings - , subq_31.booking_value - , subq_31.max_booking_value - , subq_31.min_booking_value - , subq_31.bookers - , subq_31.average_booking_value - , subq_31.referred_bookings - , subq_31.median_booking_value - , subq_31.booking_value_p99 - , subq_31.discrete_booking_value_p99 - , subq_31.approximate_continuous_booking_value_p99 - , subq_31.approximate_discrete_booking_value_p99 + subq_19.ds__day + , subq_19.ds__week + , subq_19.ds__month + , subq_19.ds__quarter + , subq_19.ds__year + , subq_19.ds__extract_year + , subq_19.ds__extract_quarter + , subq_19.ds__extract_month + , subq_19.ds__extract_day + , subq_19.ds__extract_dow + , subq_19.ds__extract_doy + , subq_19.ds_partitioned__day + , subq_19.ds_partitioned__week + , subq_19.ds_partitioned__month + , subq_19.ds_partitioned__quarter + , subq_19.ds_partitioned__year + , subq_19.ds_partitioned__extract_year + , subq_19.ds_partitioned__extract_quarter + , subq_19.ds_partitioned__extract_month + , subq_19.ds_partitioned__extract_day + , subq_19.ds_partitioned__extract_dow + , subq_19.ds_partitioned__extract_doy + , subq_19.paid_at__day + , subq_19.paid_at__week + , subq_19.paid_at__month + , subq_19.paid_at__quarter + , subq_19.paid_at__year + , subq_19.paid_at__extract_year + , subq_19.paid_at__extract_quarter + , subq_19.paid_at__extract_month + , subq_19.paid_at__extract_day + , subq_19.paid_at__extract_dow + , subq_19.paid_at__extract_doy + , subq_19.booking__ds__day + , subq_19.booking__ds__week + , subq_19.booking__ds__month + , subq_19.booking__ds__quarter + , subq_19.booking__ds__year + , subq_19.booking__ds__extract_year + , subq_19.booking__ds__extract_quarter + , subq_19.booking__ds__extract_month + , subq_19.booking__ds__extract_day + , subq_19.booking__ds__extract_dow + , subq_19.booking__ds__extract_doy + , subq_19.booking__ds_partitioned__day + , subq_19.booking__ds_partitioned__week + , subq_19.booking__ds_partitioned__month + , subq_19.booking__ds_partitioned__quarter + , subq_19.booking__ds_partitioned__year + , subq_19.booking__ds_partitioned__extract_year + , subq_19.booking__ds_partitioned__extract_quarter + , subq_19.booking__ds_partitioned__extract_month + , subq_19.booking__ds_partitioned__extract_day + , subq_19.booking__ds_partitioned__extract_dow + , subq_19.booking__ds_partitioned__extract_doy + , subq_19.booking__paid_at__day + , subq_19.booking__paid_at__week + , subq_19.booking__paid_at__month + , subq_19.booking__paid_at__quarter + , subq_19.booking__paid_at__year + , subq_19.booking__paid_at__extract_year + , subq_19.booking__paid_at__extract_quarter + , subq_19.booking__paid_at__extract_month + , subq_19.booking__paid_at__extract_day + , subq_19.booking__paid_at__extract_dow + , subq_19.booking__paid_at__extract_doy + , subq_19.ds__day AS metric_time__day + , subq_19.ds__week AS metric_time__week + , subq_19.ds__month AS metric_time__month + , subq_19.ds__quarter AS metric_time__quarter + , subq_19.ds__year AS metric_time__year + , subq_19.ds__extract_year AS metric_time__extract_year + , subq_19.ds__extract_quarter AS metric_time__extract_quarter + , subq_19.ds__extract_month AS metric_time__extract_month + , subq_19.ds__extract_day AS metric_time__extract_day + , subq_19.ds__extract_dow AS metric_time__extract_dow + , subq_19.ds__extract_doy AS metric_time__extract_doy + , subq_19.listing + , subq_19.guest + , subq_19.host + , subq_19.booking__listing + , subq_19.booking__guest + , subq_19.booking__host + , subq_19.is_instant + , subq_19.booking__is_instant + , subq_19.bookings + , subq_19.instant_bookings + , subq_19.booking_value + , subq_19.max_booking_value + , subq_19.min_booking_value + , subq_19.bookers + , subq_19.average_booking_value + , subq_19.referred_bookings + , subq_19.median_booking_value + , subq_19.booking_value_p99 + , subq_19.discrete_booking_value_p99 + , subq_19.approximate_continuous_booking_value_p99 + , subq_19.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -825,86 +825,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_31 - ) subq_32 + ) subq_19 + ) subq_20 WHERE booking__is_instant - ) subq_33 - ) subq_34 + ) subq_21 + ) subq_22 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_36.listing - , subq_36.is_lux_latest + subq_24.listing + , subq_24.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_35.ds__day - , subq_35.ds__week - , subq_35.ds__month - , subq_35.ds__quarter - , subq_35.ds__year - , subq_35.ds__extract_year - , subq_35.ds__extract_quarter - , subq_35.ds__extract_month - , subq_35.ds__extract_day - , subq_35.ds__extract_dow - , subq_35.ds__extract_doy - , subq_35.created_at__day - , subq_35.created_at__week - , subq_35.created_at__month - , subq_35.created_at__quarter - , subq_35.created_at__year - , subq_35.created_at__extract_year - , subq_35.created_at__extract_quarter - , subq_35.created_at__extract_month - , subq_35.created_at__extract_day - , subq_35.created_at__extract_dow - , subq_35.created_at__extract_doy - , subq_35.listing__ds__day - , subq_35.listing__ds__week - , subq_35.listing__ds__month - , subq_35.listing__ds__quarter - , subq_35.listing__ds__year - , subq_35.listing__ds__extract_year - , subq_35.listing__ds__extract_quarter - , subq_35.listing__ds__extract_month - , subq_35.listing__ds__extract_day - , subq_35.listing__ds__extract_dow - , subq_35.listing__ds__extract_doy - , subq_35.listing__created_at__day - , subq_35.listing__created_at__week - , subq_35.listing__created_at__month - , subq_35.listing__created_at__quarter - , subq_35.listing__created_at__year - , subq_35.listing__created_at__extract_year - , subq_35.listing__created_at__extract_quarter - , subq_35.listing__created_at__extract_month - , subq_35.listing__created_at__extract_day - , subq_35.listing__created_at__extract_dow - , subq_35.listing__created_at__extract_doy - , subq_35.ds__day AS metric_time__day - , subq_35.ds__week AS metric_time__week - , subq_35.ds__month AS metric_time__month - , subq_35.ds__quarter AS metric_time__quarter - , subq_35.ds__year AS metric_time__year - , subq_35.ds__extract_year AS metric_time__extract_year - , subq_35.ds__extract_quarter AS metric_time__extract_quarter - , subq_35.ds__extract_month AS metric_time__extract_month - , subq_35.ds__extract_day AS metric_time__extract_day - , subq_35.ds__extract_dow AS metric_time__extract_dow - , subq_35.ds__extract_doy AS metric_time__extract_doy - , subq_35.listing - , subq_35.user - , subq_35.listing__user - , subq_35.country_latest - , subq_35.is_lux_latest - , subq_35.capacity_latest - , subq_35.listing__country_latest - , subq_35.listing__is_lux_latest - , subq_35.listing__capacity_latest - , subq_35.listings - , subq_35.largest_listing - , subq_35.smallest_listing + subq_23.ds__day + , subq_23.ds__week + , subq_23.ds__month + , subq_23.ds__quarter + , subq_23.ds__year + , subq_23.ds__extract_year + , subq_23.ds__extract_quarter + , subq_23.ds__extract_month + , subq_23.ds__extract_day + , subq_23.ds__extract_dow + , subq_23.ds__extract_doy + , subq_23.created_at__day + , subq_23.created_at__week + , subq_23.created_at__month + , subq_23.created_at__quarter + , subq_23.created_at__year + , subq_23.created_at__extract_year + , subq_23.created_at__extract_quarter + , subq_23.created_at__extract_month + , subq_23.created_at__extract_day + , subq_23.created_at__extract_dow + , subq_23.created_at__extract_doy + , subq_23.listing__ds__day + , subq_23.listing__ds__week + , subq_23.listing__ds__month + , subq_23.listing__ds__quarter + , subq_23.listing__ds__year + , subq_23.listing__ds__extract_year + , subq_23.listing__ds__extract_quarter + , subq_23.listing__ds__extract_month + , subq_23.listing__ds__extract_day + , subq_23.listing__ds__extract_dow + , subq_23.listing__ds__extract_doy + , subq_23.listing__created_at__day + , subq_23.listing__created_at__week + , subq_23.listing__created_at__month + , subq_23.listing__created_at__quarter + , subq_23.listing__created_at__year + , subq_23.listing__created_at__extract_year + , subq_23.listing__created_at__extract_quarter + , subq_23.listing__created_at__extract_month + , subq_23.listing__created_at__extract_day + , subq_23.listing__created_at__extract_dow + , subq_23.listing__created_at__extract_doy + , subq_23.ds__day AS metric_time__day + , subq_23.ds__week AS metric_time__week + , subq_23.ds__month AS metric_time__month + , subq_23.ds__quarter AS metric_time__quarter + , subq_23.ds__year AS metric_time__year + , subq_23.ds__extract_year AS metric_time__extract_year + , subq_23.ds__extract_quarter AS metric_time__extract_quarter + , subq_23.ds__extract_month AS metric_time__extract_month + , subq_23.ds__extract_day AS metric_time__extract_day + , subq_23.ds__extract_dow AS metric_time__extract_dow + , subq_23.ds__extract_doy AS metric_time__extract_doy + , subq_23.listing + , subq_23.user + , subq_23.listing__user + , subq_23.country_latest + , subq_23.is_lux_latest + , subq_23.capacity_latest + , subq_23.listing__country_latest + , subq_23.listing__is_lux_latest + , subq_23.listing__capacity_latest + , subq_23.listings + , subq_23.largest_listing + , subq_23.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -965,242 +965,242 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_35 - ) subq_36 - ) subq_37 + ) subq_23 + ) subq_24 + ) subq_25 ON - subq_34.listing = subq_37.listing - ) subq_38 - ) subq_39 + subq_22.listing = subq_25.listing + ) subq_26 + ) subq_27 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_40 - ) subq_41 - ) subq_42 - ) subq_43 + ) subq_28 + ) subq_29 + ) subq_30 + ) subq_31 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_50.booking_value + subq_38.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_49.booking_value) AS booking_value + SUM(subq_37.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_48.booking_value + subq_36.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_47.booking__is_instant - , subq_47.booking_value + subq_35.booking__is_instant + , subq_35.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_46.booking__is_instant - , subq_46.booking_value + subq_34.booking__is_instant + , subq_34.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_45.ds__day - , subq_45.ds__week - , subq_45.ds__month - , subq_45.ds__quarter - , subq_45.ds__year - , subq_45.ds__extract_year - , subq_45.ds__extract_quarter - , subq_45.ds__extract_month - , subq_45.ds__extract_day - , subq_45.ds__extract_dow - , subq_45.ds__extract_doy - , subq_45.ds_partitioned__day - , subq_45.ds_partitioned__week - , subq_45.ds_partitioned__month - , subq_45.ds_partitioned__quarter - , subq_45.ds_partitioned__year - , subq_45.ds_partitioned__extract_year - , subq_45.ds_partitioned__extract_quarter - , subq_45.ds_partitioned__extract_month - , subq_45.ds_partitioned__extract_day - , subq_45.ds_partitioned__extract_dow - , subq_45.ds_partitioned__extract_doy - , subq_45.paid_at__day - , subq_45.paid_at__week - , subq_45.paid_at__month - , subq_45.paid_at__quarter - , subq_45.paid_at__year - , subq_45.paid_at__extract_year - , subq_45.paid_at__extract_quarter - , subq_45.paid_at__extract_month - , subq_45.paid_at__extract_day - , subq_45.paid_at__extract_dow - , subq_45.paid_at__extract_doy - , subq_45.booking__ds__day - , subq_45.booking__ds__week - , subq_45.booking__ds__month - , subq_45.booking__ds__quarter - , subq_45.booking__ds__year - , subq_45.booking__ds__extract_year - , subq_45.booking__ds__extract_quarter - , subq_45.booking__ds__extract_month - , subq_45.booking__ds__extract_day - , subq_45.booking__ds__extract_dow - , subq_45.booking__ds__extract_doy - , subq_45.booking__ds_partitioned__day - , subq_45.booking__ds_partitioned__week - , subq_45.booking__ds_partitioned__month - , subq_45.booking__ds_partitioned__quarter - , subq_45.booking__ds_partitioned__year - , subq_45.booking__ds_partitioned__extract_year - , subq_45.booking__ds_partitioned__extract_quarter - , subq_45.booking__ds_partitioned__extract_month - , subq_45.booking__ds_partitioned__extract_day - , subq_45.booking__ds_partitioned__extract_dow - , subq_45.booking__ds_partitioned__extract_doy - , subq_45.booking__paid_at__day - , subq_45.booking__paid_at__week - , subq_45.booking__paid_at__month - , subq_45.booking__paid_at__quarter - , subq_45.booking__paid_at__year - , subq_45.booking__paid_at__extract_year - , subq_45.booking__paid_at__extract_quarter - , subq_45.booking__paid_at__extract_month - , subq_45.booking__paid_at__extract_day - , subq_45.booking__paid_at__extract_dow - , subq_45.booking__paid_at__extract_doy - , subq_45.metric_time__day - , subq_45.metric_time__week - , subq_45.metric_time__month - , subq_45.metric_time__quarter - , subq_45.metric_time__year - , subq_45.metric_time__extract_year - , subq_45.metric_time__extract_quarter - , subq_45.metric_time__extract_month - , subq_45.metric_time__extract_day - , subq_45.metric_time__extract_dow - , subq_45.metric_time__extract_doy - , subq_45.listing - , subq_45.guest - , subq_45.host - , subq_45.booking__listing - , subq_45.booking__guest - , subq_45.booking__host - , subq_45.is_instant - , subq_45.booking__is_instant - , subq_45.bookings - , subq_45.instant_bookings - , subq_45.booking_value - , subq_45.max_booking_value - , subq_45.min_booking_value - , subq_45.bookers - , subq_45.average_booking_value - , subq_45.referred_bookings - , subq_45.median_booking_value - , subq_45.booking_value_p99 - , subq_45.discrete_booking_value_p99 - , subq_45.approximate_continuous_booking_value_p99 - , subq_45.approximate_discrete_booking_value_p99 + subq_33.ds__day + , subq_33.ds__week + , subq_33.ds__month + , subq_33.ds__quarter + , subq_33.ds__year + , subq_33.ds__extract_year + , subq_33.ds__extract_quarter + , subq_33.ds__extract_month + , subq_33.ds__extract_day + , subq_33.ds__extract_dow + , subq_33.ds__extract_doy + , subq_33.ds_partitioned__day + , subq_33.ds_partitioned__week + , subq_33.ds_partitioned__month + , subq_33.ds_partitioned__quarter + , subq_33.ds_partitioned__year + , subq_33.ds_partitioned__extract_year + , subq_33.ds_partitioned__extract_quarter + , subq_33.ds_partitioned__extract_month + , subq_33.ds_partitioned__extract_day + , subq_33.ds_partitioned__extract_dow + , subq_33.ds_partitioned__extract_doy + , subq_33.paid_at__day + , subq_33.paid_at__week + , subq_33.paid_at__month + , subq_33.paid_at__quarter + , subq_33.paid_at__year + , subq_33.paid_at__extract_year + , subq_33.paid_at__extract_quarter + , subq_33.paid_at__extract_month + , subq_33.paid_at__extract_day + , subq_33.paid_at__extract_dow + , subq_33.paid_at__extract_doy + , subq_33.booking__ds__day + , subq_33.booking__ds__week + , subq_33.booking__ds__month + , subq_33.booking__ds__quarter + , subq_33.booking__ds__year + , subq_33.booking__ds__extract_year + , subq_33.booking__ds__extract_quarter + , subq_33.booking__ds__extract_month + , subq_33.booking__ds__extract_day + , subq_33.booking__ds__extract_dow + , subq_33.booking__ds__extract_doy + , subq_33.booking__ds_partitioned__day + , subq_33.booking__ds_partitioned__week + , subq_33.booking__ds_partitioned__month + , subq_33.booking__ds_partitioned__quarter + , subq_33.booking__ds_partitioned__year + , subq_33.booking__ds_partitioned__extract_year + , subq_33.booking__ds_partitioned__extract_quarter + , subq_33.booking__ds_partitioned__extract_month + , subq_33.booking__ds_partitioned__extract_day + , subq_33.booking__ds_partitioned__extract_dow + , subq_33.booking__ds_partitioned__extract_doy + , subq_33.booking__paid_at__day + , subq_33.booking__paid_at__week + , subq_33.booking__paid_at__month + , subq_33.booking__paid_at__quarter + , subq_33.booking__paid_at__year + , subq_33.booking__paid_at__extract_year + , subq_33.booking__paid_at__extract_quarter + , subq_33.booking__paid_at__extract_month + , subq_33.booking__paid_at__extract_day + , subq_33.booking__paid_at__extract_dow + , subq_33.booking__paid_at__extract_doy + , subq_33.metric_time__day + , subq_33.metric_time__week + , subq_33.metric_time__month + , subq_33.metric_time__quarter + , subq_33.metric_time__year + , subq_33.metric_time__extract_year + , subq_33.metric_time__extract_quarter + , subq_33.metric_time__extract_month + , subq_33.metric_time__extract_day + , subq_33.metric_time__extract_dow + , subq_33.metric_time__extract_doy + , subq_33.listing + , subq_33.guest + , subq_33.host + , subq_33.booking__listing + , subq_33.booking__guest + , subq_33.booking__host + , subq_33.is_instant + , subq_33.booking__is_instant + , subq_33.bookings + , subq_33.instant_bookings + , subq_33.booking_value + , subq_33.max_booking_value + , subq_33.min_booking_value + , subq_33.bookers + , subq_33.average_booking_value + , subq_33.referred_bookings + , subq_33.median_booking_value + , subq_33.booking_value_p99 + , subq_33.discrete_booking_value_p99 + , subq_33.approximate_continuous_booking_value_p99 + , subq_33.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_44.ds__day - , subq_44.ds__week - , subq_44.ds__month - , subq_44.ds__quarter - , subq_44.ds__year - , subq_44.ds__extract_year - , subq_44.ds__extract_quarter - , subq_44.ds__extract_month - , subq_44.ds__extract_day - , subq_44.ds__extract_dow - , subq_44.ds__extract_doy - , subq_44.ds_partitioned__day - , subq_44.ds_partitioned__week - , subq_44.ds_partitioned__month - , subq_44.ds_partitioned__quarter - , subq_44.ds_partitioned__year - , subq_44.ds_partitioned__extract_year - , subq_44.ds_partitioned__extract_quarter - , subq_44.ds_partitioned__extract_month - , subq_44.ds_partitioned__extract_day - , subq_44.ds_partitioned__extract_dow - , subq_44.ds_partitioned__extract_doy - , subq_44.paid_at__day - , subq_44.paid_at__week - , subq_44.paid_at__month - , subq_44.paid_at__quarter - , subq_44.paid_at__year - , subq_44.paid_at__extract_year - , subq_44.paid_at__extract_quarter - , subq_44.paid_at__extract_month - , subq_44.paid_at__extract_day - , subq_44.paid_at__extract_dow - , subq_44.paid_at__extract_doy - , subq_44.booking__ds__day - , subq_44.booking__ds__week - , subq_44.booking__ds__month - , subq_44.booking__ds__quarter - , subq_44.booking__ds__year - , subq_44.booking__ds__extract_year - , subq_44.booking__ds__extract_quarter - , subq_44.booking__ds__extract_month - , subq_44.booking__ds__extract_day - , subq_44.booking__ds__extract_dow - , subq_44.booking__ds__extract_doy - , subq_44.booking__ds_partitioned__day - , subq_44.booking__ds_partitioned__week - , subq_44.booking__ds_partitioned__month - , subq_44.booking__ds_partitioned__quarter - , subq_44.booking__ds_partitioned__year - , subq_44.booking__ds_partitioned__extract_year - , subq_44.booking__ds_partitioned__extract_quarter - , subq_44.booking__ds_partitioned__extract_month - , subq_44.booking__ds_partitioned__extract_day - , subq_44.booking__ds_partitioned__extract_dow - , subq_44.booking__ds_partitioned__extract_doy - , subq_44.booking__paid_at__day - , subq_44.booking__paid_at__week - , subq_44.booking__paid_at__month - , subq_44.booking__paid_at__quarter - , subq_44.booking__paid_at__year - , subq_44.booking__paid_at__extract_year - , subq_44.booking__paid_at__extract_quarter - , subq_44.booking__paid_at__extract_month - , subq_44.booking__paid_at__extract_day - , subq_44.booking__paid_at__extract_dow - , subq_44.booking__paid_at__extract_doy - , subq_44.ds__day AS metric_time__day - , subq_44.ds__week AS metric_time__week - , subq_44.ds__month AS metric_time__month - , subq_44.ds__quarter AS metric_time__quarter - , subq_44.ds__year AS metric_time__year - , subq_44.ds__extract_year AS metric_time__extract_year - , subq_44.ds__extract_quarter AS metric_time__extract_quarter - , subq_44.ds__extract_month AS metric_time__extract_month - , subq_44.ds__extract_day AS metric_time__extract_day - , subq_44.ds__extract_dow AS metric_time__extract_dow - , subq_44.ds__extract_doy AS metric_time__extract_doy - , subq_44.listing - , subq_44.guest - , subq_44.host - , subq_44.booking__listing - , subq_44.booking__guest - , subq_44.booking__host - , subq_44.is_instant - , subq_44.booking__is_instant - , subq_44.bookings - , subq_44.instant_bookings - , subq_44.booking_value - , subq_44.max_booking_value - , subq_44.min_booking_value - , subq_44.bookers - , subq_44.average_booking_value - , subq_44.referred_bookings - , subq_44.median_booking_value - , subq_44.booking_value_p99 - , subq_44.discrete_booking_value_p99 - , subq_44.approximate_continuous_booking_value_p99 - , subq_44.approximate_discrete_booking_value_p99 + subq_32.ds__day + , subq_32.ds__week + , subq_32.ds__month + , subq_32.ds__quarter + , subq_32.ds__year + , subq_32.ds__extract_year + , subq_32.ds__extract_quarter + , subq_32.ds__extract_month + , subq_32.ds__extract_day + , subq_32.ds__extract_dow + , subq_32.ds__extract_doy + , subq_32.ds_partitioned__day + , subq_32.ds_partitioned__week + , subq_32.ds_partitioned__month + , subq_32.ds_partitioned__quarter + , subq_32.ds_partitioned__year + , subq_32.ds_partitioned__extract_year + , subq_32.ds_partitioned__extract_quarter + , subq_32.ds_partitioned__extract_month + , subq_32.ds_partitioned__extract_day + , subq_32.ds_partitioned__extract_dow + , subq_32.ds_partitioned__extract_doy + , subq_32.paid_at__day + , subq_32.paid_at__week + , subq_32.paid_at__month + , subq_32.paid_at__quarter + , subq_32.paid_at__year + , subq_32.paid_at__extract_year + , subq_32.paid_at__extract_quarter + , subq_32.paid_at__extract_month + , subq_32.paid_at__extract_day + , subq_32.paid_at__extract_dow + , subq_32.paid_at__extract_doy + , subq_32.booking__ds__day + , subq_32.booking__ds__week + , subq_32.booking__ds__month + , subq_32.booking__ds__quarter + , subq_32.booking__ds__year + , subq_32.booking__ds__extract_year + , subq_32.booking__ds__extract_quarter + , subq_32.booking__ds__extract_month + , subq_32.booking__ds__extract_day + , subq_32.booking__ds__extract_dow + , subq_32.booking__ds__extract_doy + , subq_32.booking__ds_partitioned__day + , subq_32.booking__ds_partitioned__week + , subq_32.booking__ds_partitioned__month + , subq_32.booking__ds_partitioned__quarter + , subq_32.booking__ds_partitioned__year + , subq_32.booking__ds_partitioned__extract_year + , subq_32.booking__ds_partitioned__extract_quarter + , subq_32.booking__ds_partitioned__extract_month + , subq_32.booking__ds_partitioned__extract_day + , subq_32.booking__ds_partitioned__extract_dow + , subq_32.booking__ds_partitioned__extract_doy + , subq_32.booking__paid_at__day + , subq_32.booking__paid_at__week + , subq_32.booking__paid_at__month + , subq_32.booking__paid_at__quarter + , subq_32.booking__paid_at__year + , subq_32.booking__paid_at__extract_year + , subq_32.booking__paid_at__extract_quarter + , subq_32.booking__paid_at__extract_month + , subq_32.booking__paid_at__extract_day + , subq_32.booking__paid_at__extract_dow + , subq_32.booking__paid_at__extract_doy + , subq_32.ds__day AS metric_time__day + , subq_32.ds__week AS metric_time__week + , subq_32.ds__month AS metric_time__month + , subq_32.ds__quarter AS metric_time__quarter + , subq_32.ds__year AS metric_time__year + , subq_32.ds__extract_year AS metric_time__extract_year + , subq_32.ds__extract_quarter AS metric_time__extract_quarter + , subq_32.ds__extract_month AS metric_time__extract_month + , subq_32.ds__extract_day AS metric_time__extract_day + , subq_32.ds__extract_dow AS metric_time__extract_dow + , subq_32.ds__extract_doy AS metric_time__extract_doy + , subq_32.listing + , subq_32.guest + , subq_32.host + , subq_32.booking__listing + , subq_32.booking__guest + , subq_32.booking__host + , subq_32.is_instant + , subq_32.booking__is_instant + , subq_32.bookings + , subq_32.instant_bookings + , subq_32.booking_value + , subq_32.max_booking_value + , subq_32.min_booking_value + , subq_32.bookers + , subq_32.average_booking_value + , subq_32.referred_bookings + , subq_32.median_booking_value + , subq_32.booking_value_p99 + , subq_32.discrete_booking_value_p99 + , subq_32.approximate_continuous_booking_value_p99 + , subq_32.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -1293,15 +1293,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_44 - ) subq_45 + ) subq_32 + ) subq_33 WHERE booking__is_instant - ) subq_46 - ) subq_47 + ) subq_34 + ) subq_35 WHERE booking__is_instant - ) subq_48 - ) subq_49 - ) subq_50 - ) subq_51 - ) subq_52 -) subq_53 + ) subq_36 + ) subq_37 + ) subq_38 + ) subq_39 + ) subq_40 +) subq_41 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/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 a0fdc735bd..60a09b752b 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_66.average_booking_value) AS average_booking_value - , MAX(subq_79.bookings) AS bookings - , MAX(subq_87.booking_value) AS booking_value + MAX(subq_54.average_booking_value) AS average_booking_value + , MAX(subq_67.bookings) AS bookings + , MAX(subq_75.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value',] @@ -22,9 +22,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_57.booking__is_instant AS booking__is_instant + subq_45.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_57.average_booking_value AS average_booking_value + , subq_45.average_booking_value AS average_booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] @@ -40,16 +40,16 @@ FROM ( , is_instant AS booking__is_instant , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_55 + ) subq_43 WHERE booking__is_instant - ) subq_57 + ) subq_45 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_57.listing = listings_latest_src_28000.listing_id - ) subq_62 + subq_45.listing = listings_latest_src_28000.listing_id + ) subq_50 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_66 + ) subq_54 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings',] @@ -61,9 +61,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_70.booking__is_instant AS booking__is_instant + subq_58.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_70.bookings AS bookings + , subq_58.bookings AS bookings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] @@ -79,16 +79,16 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_68 + ) subq_56 WHERE booking__is_instant - ) subq_70 + ) subq_58 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_70.listing = listings_latest_src_28000.listing_id - ) subq_75 + subq_58.listing = listings_latest_src_28000.listing_id + ) subq_63 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_79 + ) subq_67 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -109,10 +109,10 @@ FROM ( is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_81 + ) subq_69 WHERE booking__is_instant - ) subq_83 + ) subq_71 WHERE booking__is_instant - ) subq_87 - ) subq_88 -) subq_89 + ) subq_75 + ) subq_76 +) subq_77 diff --git a/tests_metricflow/snapshots/test_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 a54923e15b..c4c3c5c749 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_30.average_booking_value) AS average_booking_value - , MAX(subq_43.bookings) AS bookings - , MAX(subq_51.booking_value) AS booking_value + MAX(subq_18.average_booking_value) AS average_booking_value + , MAX(subq_31.bookings) AS bookings + , MAX(subq_39.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_29.average_booking_value + subq_17.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_28.average_booking_value) AS average_booking_value + AVG(subq_16.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_27.average_booking_value + subq_15.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.listing__is_lux_latest - , subq_26.average_booking_value + subq_14.booking__is_instant + , subq_14.listing__is_lux_latest + , subq_14.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_25.booking__is_instant - , subq_25.listing__is_lux_latest - , subq_25.average_booking_value + subq_13.booking__is_instant + , subq_13.listing__is_lux_latest + , subq_13.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_21.listing AS listing - , subq_21.booking__is_instant AS booking__is_instant - , subq_24.is_lux_latest AS listing__is_lux_latest - , subq_21.average_booking_value AS average_booking_value + subq_9.listing AS listing + , subq_9.booking__is_instant AS booking__is_instant + , subq_12.is_lux_latest AS listing__is_lux_latest + , subq_9.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_20.listing - , subq_20.booking__is_instant - , subq_20.average_booking_value + subq_8.listing + , subq_8.booking__is_instant + , subq_8.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_19.ds__day - , subq_19.ds__week - , subq_19.ds__month - , subq_19.ds__quarter - , subq_19.ds__year - , subq_19.ds__extract_year - , subq_19.ds__extract_quarter - , subq_19.ds__extract_month - , subq_19.ds__extract_day - , subq_19.ds__extract_dow - , subq_19.ds__extract_doy - , subq_19.ds_partitioned__day - , subq_19.ds_partitioned__week - , subq_19.ds_partitioned__month - , subq_19.ds_partitioned__quarter - , subq_19.ds_partitioned__year - , subq_19.ds_partitioned__extract_year - , subq_19.ds_partitioned__extract_quarter - , subq_19.ds_partitioned__extract_month - , subq_19.ds_partitioned__extract_day - , subq_19.ds_partitioned__extract_dow - , subq_19.ds_partitioned__extract_doy - , subq_19.paid_at__day - , subq_19.paid_at__week - , subq_19.paid_at__month - , subq_19.paid_at__quarter - , subq_19.paid_at__year - , subq_19.paid_at__extract_year - , subq_19.paid_at__extract_quarter - , subq_19.paid_at__extract_month - , subq_19.paid_at__extract_day - , subq_19.paid_at__extract_dow - , subq_19.paid_at__extract_doy - , subq_19.booking__ds__day - , subq_19.booking__ds__week - , subq_19.booking__ds__month - , subq_19.booking__ds__quarter - , subq_19.booking__ds__year - , subq_19.booking__ds__extract_year - , subq_19.booking__ds__extract_quarter - , subq_19.booking__ds__extract_month - , subq_19.booking__ds__extract_day - , subq_19.booking__ds__extract_dow - , subq_19.booking__ds__extract_doy - , subq_19.booking__ds_partitioned__day - , subq_19.booking__ds_partitioned__week - , subq_19.booking__ds_partitioned__month - , subq_19.booking__ds_partitioned__quarter - , subq_19.booking__ds_partitioned__year - , subq_19.booking__ds_partitioned__extract_year - , subq_19.booking__ds_partitioned__extract_quarter - , subq_19.booking__ds_partitioned__extract_month - , subq_19.booking__ds_partitioned__extract_day - , subq_19.booking__ds_partitioned__extract_dow - , subq_19.booking__ds_partitioned__extract_doy - , subq_19.booking__paid_at__day - , subq_19.booking__paid_at__week - , subq_19.booking__paid_at__month - , subq_19.booking__paid_at__quarter - , subq_19.booking__paid_at__year - , subq_19.booking__paid_at__extract_year - , subq_19.booking__paid_at__extract_quarter - , subq_19.booking__paid_at__extract_month - , subq_19.booking__paid_at__extract_day - , subq_19.booking__paid_at__extract_dow - , subq_19.booking__paid_at__extract_doy - , subq_19.metric_time__day - , subq_19.metric_time__week - , subq_19.metric_time__month - , subq_19.metric_time__quarter - , subq_19.metric_time__year - , subq_19.metric_time__extract_year - , subq_19.metric_time__extract_quarter - , subq_19.metric_time__extract_month - , subq_19.metric_time__extract_day - , subq_19.metric_time__extract_dow - , subq_19.metric_time__extract_doy - , subq_19.listing - , subq_19.guest - , subq_19.host - , subq_19.booking__listing - , subq_19.booking__guest - , subq_19.booking__host - , subq_19.is_instant - , subq_19.booking__is_instant - , subq_19.bookings - , subq_19.instant_bookings - , subq_19.booking_value - , subq_19.max_booking_value - , subq_19.min_booking_value - , subq_19.bookers - , subq_19.average_booking_value - , subq_19.referred_bookings - , subq_19.median_booking_value - , subq_19.booking_value_p99 - , subq_19.discrete_booking_value_p99 - , subq_19.approximate_continuous_booking_value_p99 - , subq_19.approximate_discrete_booking_value_p99 + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.ds_partitioned__day + , subq_7.ds_partitioned__week + , subq_7.ds_partitioned__month + , subq_7.ds_partitioned__quarter + , subq_7.ds_partitioned__year + , subq_7.ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy + , subq_7.paid_at__day + , subq_7.paid_at__week + , subq_7.paid_at__month + , subq_7.paid_at__quarter + , subq_7.paid_at__year + , subq_7.paid_at__extract_year + , subq_7.paid_at__extract_quarter + , subq_7.paid_at__extract_month + , subq_7.paid_at__extract_day + , subq_7.paid_at__extract_dow + , subq_7.paid_at__extract_doy + , subq_7.booking__ds__day + , subq_7.booking__ds__week + , subq_7.booking__ds__month + , subq_7.booking__ds__quarter + , subq_7.booking__ds__year + , subq_7.booking__ds__extract_year + , subq_7.booking__ds__extract_quarter + , subq_7.booking__ds__extract_month + , subq_7.booking__ds__extract_day + , subq_7.booking__ds__extract_dow + , subq_7.booking__ds__extract_doy + , subq_7.booking__ds_partitioned__day + , subq_7.booking__ds_partitioned__week + , subq_7.booking__ds_partitioned__month + , subq_7.booking__ds_partitioned__quarter + , subq_7.booking__ds_partitioned__year + , subq_7.booking__ds_partitioned__extract_year + , subq_7.booking__ds_partitioned__extract_quarter + , subq_7.booking__ds_partitioned__extract_month + , subq_7.booking__ds_partitioned__extract_day + , subq_7.booking__ds_partitioned__extract_dow + , subq_7.booking__ds_partitioned__extract_doy + , subq_7.booking__paid_at__day + , subq_7.booking__paid_at__week + , subq_7.booking__paid_at__month + , subq_7.booking__paid_at__quarter + , subq_7.booking__paid_at__year + , subq_7.booking__paid_at__extract_year + , subq_7.booking__paid_at__extract_quarter + , subq_7.booking__paid_at__extract_month + , subq_7.booking__paid_at__extract_day + , subq_7.booking__paid_at__extract_dow + , subq_7.booking__paid_at__extract_doy + , subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.metric_time__month + , subq_7.metric_time__quarter + , subq_7.metric_time__year + , subq_7.metric_time__extract_year + , subq_7.metric_time__extract_quarter + , subq_7.metric_time__extract_month + , subq_7.metric_time__extract_day + , subq_7.metric_time__extract_dow + , subq_7.metric_time__extract_doy + , subq_7.listing + , subq_7.guest + , subq_7.host + , subq_7.booking__listing + , subq_7.booking__guest + , subq_7.booking__host + , subq_7.is_instant + , subq_7.booking__is_instant + , subq_7.bookings + , subq_7.instant_bookings + , subq_7.booking_value + , subq_7.max_booking_value + , subq_7.min_booking_value + , subq_7.bookers + , subq_7.average_booking_value + , subq_7.referred_bookings + , subq_7.median_booking_value + , subq_7.booking_value_p99 + , subq_7.discrete_booking_value_p99 + , subq_7.approximate_continuous_booking_value_p99 + , subq_7.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.ds_partitioned__day - , subq_18.ds_partitioned__week - , subq_18.ds_partitioned__month - , subq_18.ds_partitioned__quarter - , subq_18.ds_partitioned__year - , subq_18.ds_partitioned__extract_year - , subq_18.ds_partitioned__extract_quarter - , subq_18.ds_partitioned__extract_month - , subq_18.ds_partitioned__extract_day - , subq_18.ds_partitioned__extract_dow - , subq_18.ds_partitioned__extract_doy - , subq_18.paid_at__day - , subq_18.paid_at__week - , subq_18.paid_at__month - , subq_18.paid_at__quarter - , subq_18.paid_at__year - , subq_18.paid_at__extract_year - , subq_18.paid_at__extract_quarter - , subq_18.paid_at__extract_month - , subq_18.paid_at__extract_day - , subq_18.paid_at__extract_dow - , subq_18.paid_at__extract_doy - , subq_18.booking__ds__day - , subq_18.booking__ds__week - , subq_18.booking__ds__month - , subq_18.booking__ds__quarter - , subq_18.booking__ds__year - , subq_18.booking__ds__extract_year - , subq_18.booking__ds__extract_quarter - , subq_18.booking__ds__extract_month - , subq_18.booking__ds__extract_day - , subq_18.booking__ds__extract_dow - , subq_18.booking__ds__extract_doy - , subq_18.booking__ds_partitioned__day - , subq_18.booking__ds_partitioned__week - , subq_18.booking__ds_partitioned__month - , subq_18.booking__ds_partitioned__quarter - , subq_18.booking__ds_partitioned__year - , subq_18.booking__ds_partitioned__extract_year - , subq_18.booking__ds_partitioned__extract_quarter - , subq_18.booking__ds_partitioned__extract_month - , subq_18.booking__ds_partitioned__extract_day - , subq_18.booking__ds_partitioned__extract_dow - , subq_18.booking__ds_partitioned__extract_doy - , subq_18.booking__paid_at__day - , subq_18.booking__paid_at__week - , subq_18.booking__paid_at__month - , subq_18.booking__paid_at__quarter - , subq_18.booking__paid_at__year - , subq_18.booking__paid_at__extract_year - , subq_18.booking__paid_at__extract_quarter - , subq_18.booking__paid_at__extract_month - , subq_18.booking__paid_at__extract_day - , subq_18.booking__paid_at__extract_dow - , subq_18.booking__paid_at__extract_doy - , subq_18.ds__day AS metric_time__day - , subq_18.ds__week AS metric_time__week - , subq_18.ds__month AS metric_time__month - , subq_18.ds__quarter AS metric_time__quarter - , subq_18.ds__year AS metric_time__year - , subq_18.ds__extract_year AS metric_time__extract_year - , subq_18.ds__extract_quarter AS metric_time__extract_quarter - , subq_18.ds__extract_month AS metric_time__extract_month - , subq_18.ds__extract_day AS metric_time__extract_day - , subq_18.ds__extract_dow AS metric_time__extract_dow - , subq_18.ds__extract_doy AS metric_time__extract_doy - , subq_18.listing - , subq_18.guest - , subq_18.host - , subq_18.booking__listing - , subq_18.booking__guest - , subq_18.booking__host - , subq_18.is_instant - , subq_18.booking__is_instant - , subq_18.bookings - , subq_18.instant_bookings - , subq_18.booking_value - , subq_18.max_booking_value - , subq_18.min_booking_value - , subq_18.bookers - , subq_18.average_booking_value - , subq_18.referred_bookings - , subq_18.median_booking_value - , subq_18.booking_value_p99 - , subq_18.discrete_booking_value_p99 - , subq_18.approximate_continuous_booking_value_p99 - , subq_18.approximate_discrete_booking_value_p99 + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -342,86 +342,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_18 - ) subq_19 + ) subq_6 + ) subq_7 WHERE booking__is_instant - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_23.listing - , subq_23.is_lux_latest + subq_11.listing + , subq_11.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_22.ds__day - , subq_22.ds__week - , subq_22.ds__month - , subq_22.ds__quarter - , subq_22.ds__year - , subq_22.ds__extract_year - , subq_22.ds__extract_quarter - , subq_22.ds__extract_month - , subq_22.ds__extract_day - , subq_22.ds__extract_dow - , subq_22.ds__extract_doy - , subq_22.created_at__day - , subq_22.created_at__week - , subq_22.created_at__month - , subq_22.created_at__quarter - , subq_22.created_at__year - , subq_22.created_at__extract_year - , subq_22.created_at__extract_quarter - , subq_22.created_at__extract_month - , subq_22.created_at__extract_day - , subq_22.created_at__extract_dow - , subq_22.created_at__extract_doy - , subq_22.listing__ds__day - , subq_22.listing__ds__week - , subq_22.listing__ds__month - , subq_22.listing__ds__quarter - , subq_22.listing__ds__year - , subq_22.listing__ds__extract_year - , subq_22.listing__ds__extract_quarter - , subq_22.listing__ds__extract_month - , subq_22.listing__ds__extract_day - , subq_22.listing__ds__extract_dow - , subq_22.listing__ds__extract_doy - , subq_22.listing__created_at__day - , subq_22.listing__created_at__week - , subq_22.listing__created_at__month - , subq_22.listing__created_at__quarter - , subq_22.listing__created_at__year - , subq_22.listing__created_at__extract_year - , subq_22.listing__created_at__extract_quarter - , subq_22.listing__created_at__extract_month - , subq_22.listing__created_at__extract_day - , subq_22.listing__created_at__extract_dow - , subq_22.listing__created_at__extract_doy - , subq_22.ds__day AS metric_time__day - , subq_22.ds__week AS metric_time__week - , subq_22.ds__month AS metric_time__month - , subq_22.ds__quarter AS metric_time__quarter - , subq_22.ds__year AS metric_time__year - , subq_22.ds__extract_year AS metric_time__extract_year - , subq_22.ds__extract_quarter AS metric_time__extract_quarter - , subq_22.ds__extract_month AS metric_time__extract_month - , subq_22.ds__extract_day AS metric_time__extract_day - , subq_22.ds__extract_dow AS metric_time__extract_dow - , subq_22.ds__extract_doy AS metric_time__extract_doy - , subq_22.listing - , subq_22.user - , subq_22.listing__user - , subq_22.country_latest - , subq_22.is_lux_latest - , subq_22.capacity_latest - , subq_22.listing__country_latest - , subq_22.listing__is_lux_latest - , subq_22.listing__capacity_latest - , subq_22.listings - , subq_22.largest_listing - , subq_22.smallest_listing + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.created_at__day + , subq_10.created_at__week + , subq_10.created_at__month + , subq_10.created_at__quarter + , subq_10.created_at__year + , subq_10.created_at__extract_year + , subq_10.created_at__extract_quarter + , subq_10.created_at__extract_month + , subq_10.created_at__extract_day + , subq_10.created_at__extract_dow + , subq_10.created_at__extract_doy + , subq_10.listing__ds__day + , subq_10.listing__ds__week + , subq_10.listing__ds__month + , subq_10.listing__ds__quarter + , subq_10.listing__ds__year + , subq_10.listing__ds__extract_year + , subq_10.listing__ds__extract_quarter + , subq_10.listing__ds__extract_month + , subq_10.listing__ds__extract_day + , subq_10.listing__ds__extract_dow + , subq_10.listing__ds__extract_doy + , subq_10.listing__created_at__day + , subq_10.listing__created_at__week + , subq_10.listing__created_at__month + , subq_10.listing__created_at__quarter + , subq_10.listing__created_at__year + , subq_10.listing__created_at__extract_year + , subq_10.listing__created_at__extract_quarter + , subq_10.listing__created_at__extract_month + , subq_10.listing__created_at__extract_day + , subq_10.listing__created_at__extract_dow + , subq_10.listing__created_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.user + , subq_10.listing__user + , subq_10.country_latest + , subq_10.is_lux_latest + , subq_10.capacity_latest + , subq_10.listing__country_latest + , subq_10.listing__is_lux_latest + , subq_10.listing__capacity_latest + , subq_10.listings + , subq_10.largest_listing + , subq_10.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -482,257 +482,257 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 - ) subq_23 - ) subq_24 + ) subq_10 + ) subq_11 + ) subq_12 ON - subq_21.listing = subq_24.listing - ) subq_25 - ) subq_26 + subq_9.listing = subq_12.listing + ) subq_13 + ) subq_14 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 + ) subq_15 + ) subq_16 + ) subq_17 + ) subq_18 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_42.bookings + subq_30.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_41.bookings) AS bookings + SUM(subq_29.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_40.bookings + subq_28.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_39.booking__is_instant - , subq_39.listing__is_lux_latest - , subq_39.bookings + subq_27.booking__is_instant + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_38.booking__is_instant - , subq_38.listing__is_lux_latest - , subq_38.bookings + subq_26.booking__is_instant + , subq_26.listing__is_lux_latest + , subq_26.bookings FROM ( -- Join Standard Outputs SELECT - subq_34.listing AS listing - , subq_34.booking__is_instant AS booking__is_instant - , subq_37.is_lux_latest AS listing__is_lux_latest - , subq_34.bookings AS bookings + subq_22.listing AS listing + , subq_22.booking__is_instant AS booking__is_instant + , subq_25.is_lux_latest AS listing__is_lux_latest + , subq_22.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_33.listing - , subq_33.booking__is_instant - , subq_33.bookings + subq_21.listing + , subq_21.booking__is_instant + , subq_21.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_32.ds__day - , subq_32.ds__week - , subq_32.ds__month - , subq_32.ds__quarter - , subq_32.ds__year - , subq_32.ds__extract_year - , subq_32.ds__extract_quarter - , subq_32.ds__extract_month - , subq_32.ds__extract_day - , subq_32.ds__extract_dow - , subq_32.ds__extract_doy - , subq_32.ds_partitioned__day - , subq_32.ds_partitioned__week - , subq_32.ds_partitioned__month - , subq_32.ds_partitioned__quarter - , subq_32.ds_partitioned__year - , subq_32.ds_partitioned__extract_year - , subq_32.ds_partitioned__extract_quarter - , subq_32.ds_partitioned__extract_month - , subq_32.ds_partitioned__extract_day - , subq_32.ds_partitioned__extract_dow - , subq_32.ds_partitioned__extract_doy - , subq_32.paid_at__day - , subq_32.paid_at__week - , subq_32.paid_at__month - , subq_32.paid_at__quarter - , subq_32.paid_at__year - , subq_32.paid_at__extract_year - , subq_32.paid_at__extract_quarter - , subq_32.paid_at__extract_month - , subq_32.paid_at__extract_day - , subq_32.paid_at__extract_dow - , subq_32.paid_at__extract_doy - , subq_32.booking__ds__day - , subq_32.booking__ds__week - , subq_32.booking__ds__month - , subq_32.booking__ds__quarter - , subq_32.booking__ds__year - , subq_32.booking__ds__extract_year - , subq_32.booking__ds__extract_quarter - , subq_32.booking__ds__extract_month - , subq_32.booking__ds__extract_day - , subq_32.booking__ds__extract_dow - , subq_32.booking__ds__extract_doy - , subq_32.booking__ds_partitioned__day - , subq_32.booking__ds_partitioned__week - , subq_32.booking__ds_partitioned__month - , subq_32.booking__ds_partitioned__quarter - , subq_32.booking__ds_partitioned__year - , subq_32.booking__ds_partitioned__extract_year - , subq_32.booking__ds_partitioned__extract_quarter - , subq_32.booking__ds_partitioned__extract_month - , subq_32.booking__ds_partitioned__extract_day - , subq_32.booking__ds_partitioned__extract_dow - , subq_32.booking__ds_partitioned__extract_doy - , subq_32.booking__paid_at__day - , subq_32.booking__paid_at__week - , subq_32.booking__paid_at__month - , subq_32.booking__paid_at__quarter - , subq_32.booking__paid_at__year - , subq_32.booking__paid_at__extract_year - , subq_32.booking__paid_at__extract_quarter - , subq_32.booking__paid_at__extract_month - , subq_32.booking__paid_at__extract_day - , subq_32.booking__paid_at__extract_dow - , subq_32.booking__paid_at__extract_doy - , subq_32.metric_time__day - , subq_32.metric_time__week - , subq_32.metric_time__month - , subq_32.metric_time__quarter - , subq_32.metric_time__year - , subq_32.metric_time__extract_year - , subq_32.metric_time__extract_quarter - , subq_32.metric_time__extract_month - , subq_32.metric_time__extract_day - , subq_32.metric_time__extract_dow - , subq_32.metric_time__extract_doy - , subq_32.listing - , subq_32.guest - , subq_32.host - , subq_32.booking__listing - , subq_32.booking__guest - , subq_32.booking__host - , subq_32.is_instant - , subq_32.booking__is_instant - , subq_32.bookings - , subq_32.instant_bookings - , subq_32.booking_value - , subq_32.max_booking_value - , subq_32.min_booking_value - , subq_32.bookers - , subq_32.average_booking_value - , subq_32.referred_bookings - , subq_32.median_booking_value - , subq_32.booking_value_p99 - , subq_32.discrete_booking_value_p99 - , subq_32.approximate_continuous_booking_value_p99 - , subq_32.approximate_discrete_booking_value_p99 + subq_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.metric_time__day + , subq_20.metric_time__week + , subq_20.metric_time__month + , subq_20.metric_time__quarter + , subq_20.metric_time__year + , subq_20.metric_time__extract_year + , subq_20.metric_time__extract_quarter + , subq_20.metric_time__extract_month + , subq_20.metric_time__extract_day + , subq_20.metric_time__extract_dow + , subq_20.metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_31.ds__day - , subq_31.ds__week - , subq_31.ds__month - , subq_31.ds__quarter - , subq_31.ds__year - , subq_31.ds__extract_year - , subq_31.ds__extract_quarter - , subq_31.ds__extract_month - , subq_31.ds__extract_day - , subq_31.ds__extract_dow - , subq_31.ds__extract_doy - , subq_31.ds_partitioned__day - , subq_31.ds_partitioned__week - , subq_31.ds_partitioned__month - , subq_31.ds_partitioned__quarter - , subq_31.ds_partitioned__year - , subq_31.ds_partitioned__extract_year - , subq_31.ds_partitioned__extract_quarter - , subq_31.ds_partitioned__extract_month - , subq_31.ds_partitioned__extract_day - , subq_31.ds_partitioned__extract_dow - , subq_31.ds_partitioned__extract_doy - , subq_31.paid_at__day - , subq_31.paid_at__week - , subq_31.paid_at__month - , subq_31.paid_at__quarter - , subq_31.paid_at__year - , subq_31.paid_at__extract_year - , subq_31.paid_at__extract_quarter - , subq_31.paid_at__extract_month - , subq_31.paid_at__extract_day - , subq_31.paid_at__extract_dow - , subq_31.paid_at__extract_doy - , subq_31.booking__ds__day - , subq_31.booking__ds__week - , subq_31.booking__ds__month - , subq_31.booking__ds__quarter - , subq_31.booking__ds__year - , subq_31.booking__ds__extract_year - , subq_31.booking__ds__extract_quarter - , subq_31.booking__ds__extract_month - , subq_31.booking__ds__extract_day - , subq_31.booking__ds__extract_dow - , subq_31.booking__ds__extract_doy - , subq_31.booking__ds_partitioned__day - , subq_31.booking__ds_partitioned__week - , subq_31.booking__ds_partitioned__month - , subq_31.booking__ds_partitioned__quarter - , subq_31.booking__ds_partitioned__year - , subq_31.booking__ds_partitioned__extract_year - , subq_31.booking__ds_partitioned__extract_quarter - , subq_31.booking__ds_partitioned__extract_month - , subq_31.booking__ds_partitioned__extract_day - , subq_31.booking__ds_partitioned__extract_dow - , subq_31.booking__ds_partitioned__extract_doy - , subq_31.booking__paid_at__day - , subq_31.booking__paid_at__week - , subq_31.booking__paid_at__month - , subq_31.booking__paid_at__quarter - , subq_31.booking__paid_at__year - , subq_31.booking__paid_at__extract_year - , subq_31.booking__paid_at__extract_quarter - , subq_31.booking__paid_at__extract_month - , subq_31.booking__paid_at__extract_day - , subq_31.booking__paid_at__extract_dow - , subq_31.booking__paid_at__extract_doy - , subq_31.ds__day AS metric_time__day - , subq_31.ds__week AS metric_time__week - , subq_31.ds__month AS metric_time__month - , subq_31.ds__quarter AS metric_time__quarter - , subq_31.ds__year AS metric_time__year - , subq_31.ds__extract_year AS metric_time__extract_year - , subq_31.ds__extract_quarter AS metric_time__extract_quarter - , subq_31.ds__extract_month AS metric_time__extract_month - , subq_31.ds__extract_day AS metric_time__extract_day - , subq_31.ds__extract_dow AS metric_time__extract_dow - , subq_31.ds__extract_doy AS metric_time__extract_doy - , subq_31.listing - , subq_31.guest - , subq_31.host - , subq_31.booking__listing - , subq_31.booking__guest - , subq_31.booking__host - , subq_31.is_instant - , subq_31.booking__is_instant - , subq_31.bookings - , subq_31.instant_bookings - , subq_31.booking_value - , subq_31.max_booking_value - , subq_31.min_booking_value - , subq_31.bookers - , subq_31.average_booking_value - , subq_31.referred_bookings - , subq_31.median_booking_value - , subq_31.booking_value_p99 - , subq_31.discrete_booking_value_p99 - , subq_31.approximate_continuous_booking_value_p99 - , subq_31.approximate_discrete_booking_value_p99 + subq_19.ds__day + , subq_19.ds__week + , subq_19.ds__month + , subq_19.ds__quarter + , subq_19.ds__year + , subq_19.ds__extract_year + , subq_19.ds__extract_quarter + , subq_19.ds__extract_month + , subq_19.ds__extract_day + , subq_19.ds__extract_dow + , subq_19.ds__extract_doy + , subq_19.ds_partitioned__day + , subq_19.ds_partitioned__week + , subq_19.ds_partitioned__month + , subq_19.ds_partitioned__quarter + , subq_19.ds_partitioned__year + , subq_19.ds_partitioned__extract_year + , subq_19.ds_partitioned__extract_quarter + , subq_19.ds_partitioned__extract_month + , subq_19.ds_partitioned__extract_day + , subq_19.ds_partitioned__extract_dow + , subq_19.ds_partitioned__extract_doy + , subq_19.paid_at__day + , subq_19.paid_at__week + , subq_19.paid_at__month + , subq_19.paid_at__quarter + , subq_19.paid_at__year + , subq_19.paid_at__extract_year + , subq_19.paid_at__extract_quarter + , subq_19.paid_at__extract_month + , subq_19.paid_at__extract_day + , subq_19.paid_at__extract_dow + , subq_19.paid_at__extract_doy + , subq_19.booking__ds__day + , subq_19.booking__ds__week + , subq_19.booking__ds__month + , subq_19.booking__ds__quarter + , subq_19.booking__ds__year + , subq_19.booking__ds__extract_year + , subq_19.booking__ds__extract_quarter + , subq_19.booking__ds__extract_month + , subq_19.booking__ds__extract_day + , subq_19.booking__ds__extract_dow + , subq_19.booking__ds__extract_doy + , subq_19.booking__ds_partitioned__day + , subq_19.booking__ds_partitioned__week + , subq_19.booking__ds_partitioned__month + , subq_19.booking__ds_partitioned__quarter + , subq_19.booking__ds_partitioned__year + , subq_19.booking__ds_partitioned__extract_year + , subq_19.booking__ds_partitioned__extract_quarter + , subq_19.booking__ds_partitioned__extract_month + , subq_19.booking__ds_partitioned__extract_day + , subq_19.booking__ds_partitioned__extract_dow + , subq_19.booking__ds_partitioned__extract_doy + , subq_19.booking__paid_at__day + , subq_19.booking__paid_at__week + , subq_19.booking__paid_at__month + , subq_19.booking__paid_at__quarter + , subq_19.booking__paid_at__year + , subq_19.booking__paid_at__extract_year + , subq_19.booking__paid_at__extract_quarter + , subq_19.booking__paid_at__extract_month + , subq_19.booking__paid_at__extract_day + , subq_19.booking__paid_at__extract_dow + , subq_19.booking__paid_at__extract_doy + , subq_19.ds__day AS metric_time__day + , subq_19.ds__week AS metric_time__week + , subq_19.ds__month AS metric_time__month + , subq_19.ds__quarter AS metric_time__quarter + , subq_19.ds__year AS metric_time__year + , subq_19.ds__extract_year AS metric_time__extract_year + , subq_19.ds__extract_quarter AS metric_time__extract_quarter + , subq_19.ds__extract_month AS metric_time__extract_month + , subq_19.ds__extract_day AS metric_time__extract_day + , subq_19.ds__extract_dow AS metric_time__extract_dow + , subq_19.ds__extract_doy AS metric_time__extract_doy + , subq_19.listing + , subq_19.guest + , subq_19.host + , subq_19.booking__listing + , subq_19.booking__guest + , subq_19.booking__host + , subq_19.is_instant + , subq_19.booking__is_instant + , subq_19.bookings + , subq_19.instant_bookings + , subq_19.booking_value + , subq_19.max_booking_value + , subq_19.min_booking_value + , subq_19.bookers + , subq_19.average_booking_value + , subq_19.referred_bookings + , subq_19.median_booking_value + , subq_19.booking_value_p99 + , subq_19.discrete_booking_value_p99 + , subq_19.approximate_continuous_booking_value_p99 + , subq_19.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -825,86 +825,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_31 - ) subq_32 + ) subq_19 + ) subq_20 WHERE booking__is_instant - ) subq_33 - ) subq_34 + ) subq_21 + ) subq_22 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_36.listing - , subq_36.is_lux_latest + subq_24.listing + , subq_24.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_35.ds__day - , subq_35.ds__week - , subq_35.ds__month - , subq_35.ds__quarter - , subq_35.ds__year - , subq_35.ds__extract_year - , subq_35.ds__extract_quarter - , subq_35.ds__extract_month - , subq_35.ds__extract_day - , subq_35.ds__extract_dow - , subq_35.ds__extract_doy - , subq_35.created_at__day - , subq_35.created_at__week - , subq_35.created_at__month - , subq_35.created_at__quarter - , subq_35.created_at__year - , subq_35.created_at__extract_year - , subq_35.created_at__extract_quarter - , subq_35.created_at__extract_month - , subq_35.created_at__extract_day - , subq_35.created_at__extract_dow - , subq_35.created_at__extract_doy - , subq_35.listing__ds__day - , subq_35.listing__ds__week - , subq_35.listing__ds__month - , subq_35.listing__ds__quarter - , subq_35.listing__ds__year - , subq_35.listing__ds__extract_year - , subq_35.listing__ds__extract_quarter - , subq_35.listing__ds__extract_month - , subq_35.listing__ds__extract_day - , subq_35.listing__ds__extract_dow - , subq_35.listing__ds__extract_doy - , subq_35.listing__created_at__day - , subq_35.listing__created_at__week - , subq_35.listing__created_at__month - , subq_35.listing__created_at__quarter - , subq_35.listing__created_at__year - , subq_35.listing__created_at__extract_year - , subq_35.listing__created_at__extract_quarter - , subq_35.listing__created_at__extract_month - , subq_35.listing__created_at__extract_day - , subq_35.listing__created_at__extract_dow - , subq_35.listing__created_at__extract_doy - , subq_35.ds__day AS metric_time__day - , subq_35.ds__week AS metric_time__week - , subq_35.ds__month AS metric_time__month - , subq_35.ds__quarter AS metric_time__quarter - , subq_35.ds__year AS metric_time__year - , subq_35.ds__extract_year AS metric_time__extract_year - , subq_35.ds__extract_quarter AS metric_time__extract_quarter - , subq_35.ds__extract_month AS metric_time__extract_month - , subq_35.ds__extract_day AS metric_time__extract_day - , subq_35.ds__extract_dow AS metric_time__extract_dow - , subq_35.ds__extract_doy AS metric_time__extract_doy - , subq_35.listing - , subq_35.user - , subq_35.listing__user - , subq_35.country_latest - , subq_35.is_lux_latest - , subq_35.capacity_latest - , subq_35.listing__country_latest - , subq_35.listing__is_lux_latest - , subq_35.listing__capacity_latest - , subq_35.listings - , subq_35.largest_listing - , subq_35.smallest_listing + subq_23.ds__day + , subq_23.ds__week + , subq_23.ds__month + , subq_23.ds__quarter + , subq_23.ds__year + , subq_23.ds__extract_year + , subq_23.ds__extract_quarter + , subq_23.ds__extract_month + , subq_23.ds__extract_day + , subq_23.ds__extract_dow + , subq_23.ds__extract_doy + , subq_23.created_at__day + , subq_23.created_at__week + , subq_23.created_at__month + , subq_23.created_at__quarter + , subq_23.created_at__year + , subq_23.created_at__extract_year + , subq_23.created_at__extract_quarter + , subq_23.created_at__extract_month + , subq_23.created_at__extract_day + , subq_23.created_at__extract_dow + , subq_23.created_at__extract_doy + , subq_23.listing__ds__day + , subq_23.listing__ds__week + , subq_23.listing__ds__month + , subq_23.listing__ds__quarter + , subq_23.listing__ds__year + , subq_23.listing__ds__extract_year + , subq_23.listing__ds__extract_quarter + , subq_23.listing__ds__extract_month + , subq_23.listing__ds__extract_day + , subq_23.listing__ds__extract_dow + , subq_23.listing__ds__extract_doy + , subq_23.listing__created_at__day + , subq_23.listing__created_at__week + , subq_23.listing__created_at__month + , subq_23.listing__created_at__quarter + , subq_23.listing__created_at__year + , subq_23.listing__created_at__extract_year + , subq_23.listing__created_at__extract_quarter + , subq_23.listing__created_at__extract_month + , subq_23.listing__created_at__extract_day + , subq_23.listing__created_at__extract_dow + , subq_23.listing__created_at__extract_doy + , subq_23.ds__day AS metric_time__day + , subq_23.ds__week AS metric_time__week + , subq_23.ds__month AS metric_time__month + , subq_23.ds__quarter AS metric_time__quarter + , subq_23.ds__year AS metric_time__year + , subq_23.ds__extract_year AS metric_time__extract_year + , subq_23.ds__extract_quarter AS metric_time__extract_quarter + , subq_23.ds__extract_month AS metric_time__extract_month + , subq_23.ds__extract_day AS metric_time__extract_day + , subq_23.ds__extract_dow AS metric_time__extract_dow + , subq_23.ds__extract_doy AS metric_time__extract_doy + , subq_23.listing + , subq_23.user + , subq_23.listing__user + , subq_23.country_latest + , subq_23.is_lux_latest + , subq_23.capacity_latest + , subq_23.listing__country_latest + , subq_23.listing__is_lux_latest + , subq_23.listing__capacity_latest + , subq_23.listings + , subq_23.largest_listing + , subq_23.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -965,242 +965,242 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_35 - ) subq_36 - ) subq_37 + ) subq_23 + ) subq_24 + ) subq_25 ON - subq_34.listing = subq_37.listing - ) subq_38 - ) subq_39 + subq_22.listing = subq_25.listing + ) subq_26 + ) subq_27 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_40 - ) subq_41 - ) subq_42 - ) subq_43 + ) subq_28 + ) subq_29 + ) subq_30 + ) subq_31 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_50.booking_value + subq_38.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_49.booking_value) AS booking_value + SUM(subq_37.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_48.booking_value + subq_36.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_47.booking__is_instant - , subq_47.booking_value + subq_35.booking__is_instant + , subq_35.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_46.booking__is_instant - , subq_46.booking_value + subq_34.booking__is_instant + , subq_34.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_45.ds__day - , subq_45.ds__week - , subq_45.ds__month - , subq_45.ds__quarter - , subq_45.ds__year - , subq_45.ds__extract_year - , subq_45.ds__extract_quarter - , subq_45.ds__extract_month - , subq_45.ds__extract_day - , subq_45.ds__extract_dow - , subq_45.ds__extract_doy - , subq_45.ds_partitioned__day - , subq_45.ds_partitioned__week - , subq_45.ds_partitioned__month - , subq_45.ds_partitioned__quarter - , subq_45.ds_partitioned__year - , subq_45.ds_partitioned__extract_year - , subq_45.ds_partitioned__extract_quarter - , subq_45.ds_partitioned__extract_month - , subq_45.ds_partitioned__extract_day - , subq_45.ds_partitioned__extract_dow - , subq_45.ds_partitioned__extract_doy - , subq_45.paid_at__day - , subq_45.paid_at__week - , subq_45.paid_at__month - , subq_45.paid_at__quarter - , subq_45.paid_at__year - , subq_45.paid_at__extract_year - , subq_45.paid_at__extract_quarter - , subq_45.paid_at__extract_month - , subq_45.paid_at__extract_day - , subq_45.paid_at__extract_dow - , subq_45.paid_at__extract_doy - , subq_45.booking__ds__day - , subq_45.booking__ds__week - , subq_45.booking__ds__month - , subq_45.booking__ds__quarter - , subq_45.booking__ds__year - , subq_45.booking__ds__extract_year - , subq_45.booking__ds__extract_quarter - , subq_45.booking__ds__extract_month - , subq_45.booking__ds__extract_day - , subq_45.booking__ds__extract_dow - , subq_45.booking__ds__extract_doy - , subq_45.booking__ds_partitioned__day - , subq_45.booking__ds_partitioned__week - , subq_45.booking__ds_partitioned__month - , subq_45.booking__ds_partitioned__quarter - , subq_45.booking__ds_partitioned__year - , subq_45.booking__ds_partitioned__extract_year - , subq_45.booking__ds_partitioned__extract_quarter - , subq_45.booking__ds_partitioned__extract_month - , subq_45.booking__ds_partitioned__extract_day - , subq_45.booking__ds_partitioned__extract_dow - , subq_45.booking__ds_partitioned__extract_doy - , subq_45.booking__paid_at__day - , subq_45.booking__paid_at__week - , subq_45.booking__paid_at__month - , subq_45.booking__paid_at__quarter - , subq_45.booking__paid_at__year - , subq_45.booking__paid_at__extract_year - , subq_45.booking__paid_at__extract_quarter - , subq_45.booking__paid_at__extract_month - , subq_45.booking__paid_at__extract_day - , subq_45.booking__paid_at__extract_dow - , subq_45.booking__paid_at__extract_doy - , subq_45.metric_time__day - , subq_45.metric_time__week - , subq_45.metric_time__month - , subq_45.metric_time__quarter - , subq_45.metric_time__year - , subq_45.metric_time__extract_year - , subq_45.metric_time__extract_quarter - , subq_45.metric_time__extract_month - , subq_45.metric_time__extract_day - , subq_45.metric_time__extract_dow - , subq_45.metric_time__extract_doy - , subq_45.listing - , subq_45.guest - , subq_45.host - , subq_45.booking__listing - , subq_45.booking__guest - , subq_45.booking__host - , subq_45.is_instant - , subq_45.booking__is_instant - , subq_45.bookings - , subq_45.instant_bookings - , subq_45.booking_value - , subq_45.max_booking_value - , subq_45.min_booking_value - , subq_45.bookers - , subq_45.average_booking_value - , subq_45.referred_bookings - , subq_45.median_booking_value - , subq_45.booking_value_p99 - , subq_45.discrete_booking_value_p99 - , subq_45.approximate_continuous_booking_value_p99 - , subq_45.approximate_discrete_booking_value_p99 + subq_33.ds__day + , subq_33.ds__week + , subq_33.ds__month + , subq_33.ds__quarter + , subq_33.ds__year + , subq_33.ds__extract_year + , subq_33.ds__extract_quarter + , subq_33.ds__extract_month + , subq_33.ds__extract_day + , subq_33.ds__extract_dow + , subq_33.ds__extract_doy + , subq_33.ds_partitioned__day + , subq_33.ds_partitioned__week + , subq_33.ds_partitioned__month + , subq_33.ds_partitioned__quarter + , subq_33.ds_partitioned__year + , subq_33.ds_partitioned__extract_year + , subq_33.ds_partitioned__extract_quarter + , subq_33.ds_partitioned__extract_month + , subq_33.ds_partitioned__extract_day + , subq_33.ds_partitioned__extract_dow + , subq_33.ds_partitioned__extract_doy + , subq_33.paid_at__day + , subq_33.paid_at__week + , subq_33.paid_at__month + , subq_33.paid_at__quarter + , subq_33.paid_at__year + , subq_33.paid_at__extract_year + , subq_33.paid_at__extract_quarter + , subq_33.paid_at__extract_month + , subq_33.paid_at__extract_day + , subq_33.paid_at__extract_dow + , subq_33.paid_at__extract_doy + , subq_33.booking__ds__day + , subq_33.booking__ds__week + , subq_33.booking__ds__month + , subq_33.booking__ds__quarter + , subq_33.booking__ds__year + , subq_33.booking__ds__extract_year + , subq_33.booking__ds__extract_quarter + , subq_33.booking__ds__extract_month + , subq_33.booking__ds__extract_day + , subq_33.booking__ds__extract_dow + , subq_33.booking__ds__extract_doy + , subq_33.booking__ds_partitioned__day + , subq_33.booking__ds_partitioned__week + , subq_33.booking__ds_partitioned__month + , subq_33.booking__ds_partitioned__quarter + , subq_33.booking__ds_partitioned__year + , subq_33.booking__ds_partitioned__extract_year + , subq_33.booking__ds_partitioned__extract_quarter + , subq_33.booking__ds_partitioned__extract_month + , subq_33.booking__ds_partitioned__extract_day + , subq_33.booking__ds_partitioned__extract_dow + , subq_33.booking__ds_partitioned__extract_doy + , subq_33.booking__paid_at__day + , subq_33.booking__paid_at__week + , subq_33.booking__paid_at__month + , subq_33.booking__paid_at__quarter + , subq_33.booking__paid_at__year + , subq_33.booking__paid_at__extract_year + , subq_33.booking__paid_at__extract_quarter + , subq_33.booking__paid_at__extract_month + , subq_33.booking__paid_at__extract_day + , subq_33.booking__paid_at__extract_dow + , subq_33.booking__paid_at__extract_doy + , subq_33.metric_time__day + , subq_33.metric_time__week + , subq_33.metric_time__month + , subq_33.metric_time__quarter + , subq_33.metric_time__year + , subq_33.metric_time__extract_year + , subq_33.metric_time__extract_quarter + , subq_33.metric_time__extract_month + , subq_33.metric_time__extract_day + , subq_33.metric_time__extract_dow + , subq_33.metric_time__extract_doy + , subq_33.listing + , subq_33.guest + , subq_33.host + , subq_33.booking__listing + , subq_33.booking__guest + , subq_33.booking__host + , subq_33.is_instant + , subq_33.booking__is_instant + , subq_33.bookings + , subq_33.instant_bookings + , subq_33.booking_value + , subq_33.max_booking_value + , subq_33.min_booking_value + , subq_33.bookers + , subq_33.average_booking_value + , subq_33.referred_bookings + , subq_33.median_booking_value + , subq_33.booking_value_p99 + , subq_33.discrete_booking_value_p99 + , subq_33.approximate_continuous_booking_value_p99 + , subq_33.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_44.ds__day - , subq_44.ds__week - , subq_44.ds__month - , subq_44.ds__quarter - , subq_44.ds__year - , subq_44.ds__extract_year - , subq_44.ds__extract_quarter - , subq_44.ds__extract_month - , subq_44.ds__extract_day - , subq_44.ds__extract_dow - , subq_44.ds__extract_doy - , subq_44.ds_partitioned__day - , subq_44.ds_partitioned__week - , subq_44.ds_partitioned__month - , subq_44.ds_partitioned__quarter - , subq_44.ds_partitioned__year - , subq_44.ds_partitioned__extract_year - , subq_44.ds_partitioned__extract_quarter - , subq_44.ds_partitioned__extract_month - , subq_44.ds_partitioned__extract_day - , subq_44.ds_partitioned__extract_dow - , subq_44.ds_partitioned__extract_doy - , subq_44.paid_at__day - , subq_44.paid_at__week - , subq_44.paid_at__month - , subq_44.paid_at__quarter - , subq_44.paid_at__year - , subq_44.paid_at__extract_year - , subq_44.paid_at__extract_quarter - , subq_44.paid_at__extract_month - , subq_44.paid_at__extract_day - , subq_44.paid_at__extract_dow - , subq_44.paid_at__extract_doy - , subq_44.booking__ds__day - , subq_44.booking__ds__week - , subq_44.booking__ds__month - , subq_44.booking__ds__quarter - , subq_44.booking__ds__year - , subq_44.booking__ds__extract_year - , subq_44.booking__ds__extract_quarter - , subq_44.booking__ds__extract_month - , subq_44.booking__ds__extract_day - , subq_44.booking__ds__extract_dow - , subq_44.booking__ds__extract_doy - , subq_44.booking__ds_partitioned__day - , subq_44.booking__ds_partitioned__week - , subq_44.booking__ds_partitioned__month - , subq_44.booking__ds_partitioned__quarter - , subq_44.booking__ds_partitioned__year - , subq_44.booking__ds_partitioned__extract_year - , subq_44.booking__ds_partitioned__extract_quarter - , subq_44.booking__ds_partitioned__extract_month - , subq_44.booking__ds_partitioned__extract_day - , subq_44.booking__ds_partitioned__extract_dow - , subq_44.booking__ds_partitioned__extract_doy - , subq_44.booking__paid_at__day - , subq_44.booking__paid_at__week - , subq_44.booking__paid_at__month - , subq_44.booking__paid_at__quarter - , subq_44.booking__paid_at__year - , subq_44.booking__paid_at__extract_year - , subq_44.booking__paid_at__extract_quarter - , subq_44.booking__paid_at__extract_month - , subq_44.booking__paid_at__extract_day - , subq_44.booking__paid_at__extract_dow - , subq_44.booking__paid_at__extract_doy - , subq_44.ds__day AS metric_time__day - , subq_44.ds__week AS metric_time__week - , subq_44.ds__month AS metric_time__month - , subq_44.ds__quarter AS metric_time__quarter - , subq_44.ds__year AS metric_time__year - , subq_44.ds__extract_year AS metric_time__extract_year - , subq_44.ds__extract_quarter AS metric_time__extract_quarter - , subq_44.ds__extract_month AS metric_time__extract_month - , subq_44.ds__extract_day AS metric_time__extract_day - , subq_44.ds__extract_dow AS metric_time__extract_dow - , subq_44.ds__extract_doy AS metric_time__extract_doy - , subq_44.listing - , subq_44.guest - , subq_44.host - , subq_44.booking__listing - , subq_44.booking__guest - , subq_44.booking__host - , subq_44.is_instant - , subq_44.booking__is_instant - , subq_44.bookings - , subq_44.instant_bookings - , subq_44.booking_value - , subq_44.max_booking_value - , subq_44.min_booking_value - , subq_44.bookers - , subq_44.average_booking_value - , subq_44.referred_bookings - , subq_44.median_booking_value - , subq_44.booking_value_p99 - , subq_44.discrete_booking_value_p99 - , subq_44.approximate_continuous_booking_value_p99 - , subq_44.approximate_discrete_booking_value_p99 + subq_32.ds__day + , subq_32.ds__week + , subq_32.ds__month + , subq_32.ds__quarter + , subq_32.ds__year + , subq_32.ds__extract_year + , subq_32.ds__extract_quarter + , subq_32.ds__extract_month + , subq_32.ds__extract_day + , subq_32.ds__extract_dow + , subq_32.ds__extract_doy + , subq_32.ds_partitioned__day + , subq_32.ds_partitioned__week + , subq_32.ds_partitioned__month + , subq_32.ds_partitioned__quarter + , subq_32.ds_partitioned__year + , subq_32.ds_partitioned__extract_year + , subq_32.ds_partitioned__extract_quarter + , subq_32.ds_partitioned__extract_month + , subq_32.ds_partitioned__extract_day + , subq_32.ds_partitioned__extract_dow + , subq_32.ds_partitioned__extract_doy + , subq_32.paid_at__day + , subq_32.paid_at__week + , subq_32.paid_at__month + , subq_32.paid_at__quarter + , subq_32.paid_at__year + , subq_32.paid_at__extract_year + , subq_32.paid_at__extract_quarter + , subq_32.paid_at__extract_month + , subq_32.paid_at__extract_day + , subq_32.paid_at__extract_dow + , subq_32.paid_at__extract_doy + , subq_32.booking__ds__day + , subq_32.booking__ds__week + , subq_32.booking__ds__month + , subq_32.booking__ds__quarter + , subq_32.booking__ds__year + , subq_32.booking__ds__extract_year + , subq_32.booking__ds__extract_quarter + , subq_32.booking__ds__extract_month + , subq_32.booking__ds__extract_day + , subq_32.booking__ds__extract_dow + , subq_32.booking__ds__extract_doy + , subq_32.booking__ds_partitioned__day + , subq_32.booking__ds_partitioned__week + , subq_32.booking__ds_partitioned__month + , subq_32.booking__ds_partitioned__quarter + , subq_32.booking__ds_partitioned__year + , subq_32.booking__ds_partitioned__extract_year + , subq_32.booking__ds_partitioned__extract_quarter + , subq_32.booking__ds_partitioned__extract_month + , subq_32.booking__ds_partitioned__extract_day + , subq_32.booking__ds_partitioned__extract_dow + , subq_32.booking__ds_partitioned__extract_doy + , subq_32.booking__paid_at__day + , subq_32.booking__paid_at__week + , subq_32.booking__paid_at__month + , subq_32.booking__paid_at__quarter + , subq_32.booking__paid_at__year + , subq_32.booking__paid_at__extract_year + , subq_32.booking__paid_at__extract_quarter + , subq_32.booking__paid_at__extract_month + , subq_32.booking__paid_at__extract_day + , subq_32.booking__paid_at__extract_dow + , subq_32.booking__paid_at__extract_doy + , subq_32.ds__day AS metric_time__day + , subq_32.ds__week AS metric_time__week + , subq_32.ds__month AS metric_time__month + , subq_32.ds__quarter AS metric_time__quarter + , subq_32.ds__year AS metric_time__year + , subq_32.ds__extract_year AS metric_time__extract_year + , subq_32.ds__extract_quarter AS metric_time__extract_quarter + , subq_32.ds__extract_month AS metric_time__extract_month + , subq_32.ds__extract_day AS metric_time__extract_day + , subq_32.ds__extract_dow AS metric_time__extract_dow + , subq_32.ds__extract_doy AS metric_time__extract_doy + , subq_32.listing + , subq_32.guest + , subq_32.host + , subq_32.booking__listing + , subq_32.booking__guest + , subq_32.booking__host + , subq_32.is_instant + , subq_32.booking__is_instant + , subq_32.bookings + , subq_32.instant_bookings + , subq_32.booking_value + , subq_32.max_booking_value + , subq_32.min_booking_value + , subq_32.bookers + , subq_32.average_booking_value + , subq_32.referred_bookings + , subq_32.median_booking_value + , subq_32.booking_value_p99 + , subq_32.discrete_booking_value_p99 + , subq_32.approximate_continuous_booking_value_p99 + , subq_32.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -1293,15 +1293,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_44 - ) subq_45 + ) subq_32 + ) subq_33 WHERE booking__is_instant - ) subq_46 - ) subq_47 + ) subq_34 + ) subq_35 WHERE booking__is_instant - ) subq_48 - ) subq_49 - ) subq_50 - ) subq_51 - ) subq_52 -) subq_53 + ) subq_36 + ) subq_37 + ) subq_38 + ) subq_39 + ) subq_40 +) subq_41 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/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 a0fdc735bd..60a09b752b 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_66.average_booking_value) AS average_booking_value - , MAX(subq_79.bookings) AS bookings - , MAX(subq_87.booking_value) AS booking_value + MAX(subq_54.average_booking_value) AS average_booking_value + , MAX(subq_67.bookings) AS bookings + , MAX(subq_75.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value',] @@ -22,9 +22,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_57.booking__is_instant AS booking__is_instant + subq_45.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_57.average_booking_value AS average_booking_value + , subq_45.average_booking_value AS average_booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] @@ -40,16 +40,16 @@ FROM ( , is_instant AS booking__is_instant , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_55 + ) subq_43 WHERE booking__is_instant - ) subq_57 + ) subq_45 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_57.listing = listings_latest_src_28000.listing_id - ) subq_62 + subq_45.listing = listings_latest_src_28000.listing_id + ) subq_50 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_66 + ) subq_54 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings',] @@ -61,9 +61,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_70.booking__is_instant AS booking__is_instant + subq_58.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_70.bookings AS bookings + , subq_58.bookings AS bookings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] @@ -79,16 +79,16 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_68 + ) subq_56 WHERE booking__is_instant - ) subq_70 + ) subq_58 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_70.listing = listings_latest_src_28000.listing_id - ) subq_75 + subq_58.listing = listings_latest_src_28000.listing_id + ) subq_63 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_79 + ) subq_67 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -109,10 +109,10 @@ FROM ( is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_81 + ) subq_69 WHERE booking__is_instant - ) subq_83 + ) subq_71 WHERE booking__is_instant - ) subq_87 - ) subq_88 -) subq_89 + ) subq_75 + ) subq_76 +) subq_77 diff --git a/tests_metricflow/snapshots/test_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 3b1d93b7d3..c6a4999e10 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_30.average_booking_value) AS average_booking_value - , MAX(subq_43.bookings) AS bookings - , MAX(subq_51.booking_value) AS booking_value + MAX(subq_18.average_booking_value) AS average_booking_value + , MAX(subq_31.bookings) AS bookings + , MAX(subq_39.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_29.average_booking_value + subq_17.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_28.average_booking_value) AS average_booking_value + AVG(subq_16.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_27.average_booking_value + subq_15.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.listing__is_lux_latest - , subq_26.average_booking_value + subq_14.booking__is_instant + , subq_14.listing__is_lux_latest + , subq_14.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_25.booking__is_instant - , subq_25.listing__is_lux_latest - , subq_25.average_booking_value + subq_13.booking__is_instant + , subq_13.listing__is_lux_latest + , subq_13.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_21.listing AS listing - , subq_21.booking__is_instant AS booking__is_instant - , subq_24.is_lux_latest AS listing__is_lux_latest - , subq_21.average_booking_value AS average_booking_value + subq_9.listing AS listing + , subq_9.booking__is_instant AS booking__is_instant + , subq_12.is_lux_latest AS listing__is_lux_latest + , subq_9.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_20.listing - , subq_20.booking__is_instant - , subq_20.average_booking_value + subq_8.listing + , subq_8.booking__is_instant + , subq_8.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_19.ds__day - , subq_19.ds__week - , subq_19.ds__month - , subq_19.ds__quarter - , subq_19.ds__year - , subq_19.ds__extract_year - , subq_19.ds__extract_quarter - , subq_19.ds__extract_month - , subq_19.ds__extract_day - , subq_19.ds__extract_dow - , subq_19.ds__extract_doy - , subq_19.ds_partitioned__day - , subq_19.ds_partitioned__week - , subq_19.ds_partitioned__month - , subq_19.ds_partitioned__quarter - , subq_19.ds_partitioned__year - , subq_19.ds_partitioned__extract_year - , subq_19.ds_partitioned__extract_quarter - , subq_19.ds_partitioned__extract_month - , subq_19.ds_partitioned__extract_day - , subq_19.ds_partitioned__extract_dow - , subq_19.ds_partitioned__extract_doy - , subq_19.paid_at__day - , subq_19.paid_at__week - , subq_19.paid_at__month - , subq_19.paid_at__quarter - , subq_19.paid_at__year - , subq_19.paid_at__extract_year - , subq_19.paid_at__extract_quarter - , subq_19.paid_at__extract_month - , subq_19.paid_at__extract_day - , subq_19.paid_at__extract_dow - , subq_19.paid_at__extract_doy - , subq_19.booking__ds__day - , subq_19.booking__ds__week - , subq_19.booking__ds__month - , subq_19.booking__ds__quarter - , subq_19.booking__ds__year - , subq_19.booking__ds__extract_year - , subq_19.booking__ds__extract_quarter - , subq_19.booking__ds__extract_month - , subq_19.booking__ds__extract_day - , subq_19.booking__ds__extract_dow - , subq_19.booking__ds__extract_doy - , subq_19.booking__ds_partitioned__day - , subq_19.booking__ds_partitioned__week - , subq_19.booking__ds_partitioned__month - , subq_19.booking__ds_partitioned__quarter - , subq_19.booking__ds_partitioned__year - , subq_19.booking__ds_partitioned__extract_year - , subq_19.booking__ds_partitioned__extract_quarter - , subq_19.booking__ds_partitioned__extract_month - , subq_19.booking__ds_partitioned__extract_day - , subq_19.booking__ds_partitioned__extract_dow - , subq_19.booking__ds_partitioned__extract_doy - , subq_19.booking__paid_at__day - , subq_19.booking__paid_at__week - , subq_19.booking__paid_at__month - , subq_19.booking__paid_at__quarter - , subq_19.booking__paid_at__year - , subq_19.booking__paid_at__extract_year - , subq_19.booking__paid_at__extract_quarter - , subq_19.booking__paid_at__extract_month - , subq_19.booking__paid_at__extract_day - , subq_19.booking__paid_at__extract_dow - , subq_19.booking__paid_at__extract_doy - , subq_19.metric_time__day - , subq_19.metric_time__week - , subq_19.metric_time__month - , subq_19.metric_time__quarter - , subq_19.metric_time__year - , subq_19.metric_time__extract_year - , subq_19.metric_time__extract_quarter - , subq_19.metric_time__extract_month - , subq_19.metric_time__extract_day - , subq_19.metric_time__extract_dow - , subq_19.metric_time__extract_doy - , subq_19.listing - , subq_19.guest - , subq_19.host - , subq_19.booking__listing - , subq_19.booking__guest - , subq_19.booking__host - , subq_19.is_instant - , subq_19.booking__is_instant - , subq_19.bookings - , subq_19.instant_bookings - , subq_19.booking_value - , subq_19.max_booking_value - , subq_19.min_booking_value - , subq_19.bookers - , subq_19.average_booking_value - , subq_19.referred_bookings - , subq_19.median_booking_value - , subq_19.booking_value_p99 - , subq_19.discrete_booking_value_p99 - , subq_19.approximate_continuous_booking_value_p99 - , subq_19.approximate_discrete_booking_value_p99 + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.ds_partitioned__day + , subq_7.ds_partitioned__week + , subq_7.ds_partitioned__month + , subq_7.ds_partitioned__quarter + , subq_7.ds_partitioned__year + , subq_7.ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy + , subq_7.paid_at__day + , subq_7.paid_at__week + , subq_7.paid_at__month + , subq_7.paid_at__quarter + , subq_7.paid_at__year + , subq_7.paid_at__extract_year + , subq_7.paid_at__extract_quarter + , subq_7.paid_at__extract_month + , subq_7.paid_at__extract_day + , subq_7.paid_at__extract_dow + , subq_7.paid_at__extract_doy + , subq_7.booking__ds__day + , subq_7.booking__ds__week + , subq_7.booking__ds__month + , subq_7.booking__ds__quarter + , subq_7.booking__ds__year + , subq_7.booking__ds__extract_year + , subq_7.booking__ds__extract_quarter + , subq_7.booking__ds__extract_month + , subq_7.booking__ds__extract_day + , subq_7.booking__ds__extract_dow + , subq_7.booking__ds__extract_doy + , subq_7.booking__ds_partitioned__day + , subq_7.booking__ds_partitioned__week + , subq_7.booking__ds_partitioned__month + , subq_7.booking__ds_partitioned__quarter + , subq_7.booking__ds_partitioned__year + , subq_7.booking__ds_partitioned__extract_year + , subq_7.booking__ds_partitioned__extract_quarter + , subq_7.booking__ds_partitioned__extract_month + , subq_7.booking__ds_partitioned__extract_day + , subq_7.booking__ds_partitioned__extract_dow + , subq_7.booking__ds_partitioned__extract_doy + , subq_7.booking__paid_at__day + , subq_7.booking__paid_at__week + , subq_7.booking__paid_at__month + , subq_7.booking__paid_at__quarter + , subq_7.booking__paid_at__year + , subq_7.booking__paid_at__extract_year + , subq_7.booking__paid_at__extract_quarter + , subq_7.booking__paid_at__extract_month + , subq_7.booking__paid_at__extract_day + , subq_7.booking__paid_at__extract_dow + , subq_7.booking__paid_at__extract_doy + , subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.metric_time__month + , subq_7.metric_time__quarter + , subq_7.metric_time__year + , subq_7.metric_time__extract_year + , subq_7.metric_time__extract_quarter + , subq_7.metric_time__extract_month + , subq_7.metric_time__extract_day + , subq_7.metric_time__extract_dow + , subq_7.metric_time__extract_doy + , subq_7.listing + , subq_7.guest + , subq_7.host + , subq_7.booking__listing + , subq_7.booking__guest + , subq_7.booking__host + , subq_7.is_instant + , subq_7.booking__is_instant + , subq_7.bookings + , subq_7.instant_bookings + , subq_7.booking_value + , subq_7.max_booking_value + , subq_7.min_booking_value + , subq_7.bookers + , subq_7.average_booking_value + , subq_7.referred_bookings + , subq_7.median_booking_value + , subq_7.booking_value_p99 + , subq_7.discrete_booking_value_p99 + , subq_7.approximate_continuous_booking_value_p99 + , subq_7.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.ds_partitioned__day - , subq_18.ds_partitioned__week - , subq_18.ds_partitioned__month - , subq_18.ds_partitioned__quarter - , subq_18.ds_partitioned__year - , subq_18.ds_partitioned__extract_year - , subq_18.ds_partitioned__extract_quarter - , subq_18.ds_partitioned__extract_month - , subq_18.ds_partitioned__extract_day - , subq_18.ds_partitioned__extract_dow - , subq_18.ds_partitioned__extract_doy - , subq_18.paid_at__day - , subq_18.paid_at__week - , subq_18.paid_at__month - , subq_18.paid_at__quarter - , subq_18.paid_at__year - , subq_18.paid_at__extract_year - , subq_18.paid_at__extract_quarter - , subq_18.paid_at__extract_month - , subq_18.paid_at__extract_day - , subq_18.paid_at__extract_dow - , subq_18.paid_at__extract_doy - , subq_18.booking__ds__day - , subq_18.booking__ds__week - , subq_18.booking__ds__month - , subq_18.booking__ds__quarter - , subq_18.booking__ds__year - , subq_18.booking__ds__extract_year - , subq_18.booking__ds__extract_quarter - , subq_18.booking__ds__extract_month - , subq_18.booking__ds__extract_day - , subq_18.booking__ds__extract_dow - , subq_18.booking__ds__extract_doy - , subq_18.booking__ds_partitioned__day - , subq_18.booking__ds_partitioned__week - , subq_18.booking__ds_partitioned__month - , subq_18.booking__ds_partitioned__quarter - , subq_18.booking__ds_partitioned__year - , subq_18.booking__ds_partitioned__extract_year - , subq_18.booking__ds_partitioned__extract_quarter - , subq_18.booking__ds_partitioned__extract_month - , subq_18.booking__ds_partitioned__extract_day - , subq_18.booking__ds_partitioned__extract_dow - , subq_18.booking__ds_partitioned__extract_doy - , subq_18.booking__paid_at__day - , subq_18.booking__paid_at__week - , subq_18.booking__paid_at__month - , subq_18.booking__paid_at__quarter - , subq_18.booking__paid_at__year - , subq_18.booking__paid_at__extract_year - , subq_18.booking__paid_at__extract_quarter - , subq_18.booking__paid_at__extract_month - , subq_18.booking__paid_at__extract_day - , subq_18.booking__paid_at__extract_dow - , subq_18.booking__paid_at__extract_doy - , subq_18.ds__day AS metric_time__day - , subq_18.ds__week AS metric_time__week - , subq_18.ds__month AS metric_time__month - , subq_18.ds__quarter AS metric_time__quarter - , subq_18.ds__year AS metric_time__year - , subq_18.ds__extract_year AS metric_time__extract_year - , subq_18.ds__extract_quarter AS metric_time__extract_quarter - , subq_18.ds__extract_month AS metric_time__extract_month - , subq_18.ds__extract_day AS metric_time__extract_day - , subq_18.ds__extract_dow AS metric_time__extract_dow - , subq_18.ds__extract_doy AS metric_time__extract_doy - , subq_18.listing - , subq_18.guest - , subq_18.host - , subq_18.booking__listing - , subq_18.booking__guest - , subq_18.booking__host - , subq_18.is_instant - , subq_18.booking__is_instant - , subq_18.bookings - , subq_18.instant_bookings - , subq_18.booking_value - , subq_18.max_booking_value - , subq_18.min_booking_value - , subq_18.bookers - , subq_18.average_booking_value - , subq_18.referred_bookings - , subq_18.median_booking_value - , subq_18.booking_value_p99 - , subq_18.discrete_booking_value_p99 - , subq_18.approximate_continuous_booking_value_p99 - , subq_18.approximate_discrete_booking_value_p99 + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -342,86 +342,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_18 - ) subq_19 + ) subq_6 + ) subq_7 WHERE booking__is_instant - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_23.listing - , subq_23.is_lux_latest + subq_11.listing + , subq_11.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_22.ds__day - , subq_22.ds__week - , subq_22.ds__month - , subq_22.ds__quarter - , subq_22.ds__year - , subq_22.ds__extract_year - , subq_22.ds__extract_quarter - , subq_22.ds__extract_month - , subq_22.ds__extract_day - , subq_22.ds__extract_dow - , subq_22.ds__extract_doy - , subq_22.created_at__day - , subq_22.created_at__week - , subq_22.created_at__month - , subq_22.created_at__quarter - , subq_22.created_at__year - , subq_22.created_at__extract_year - , subq_22.created_at__extract_quarter - , subq_22.created_at__extract_month - , subq_22.created_at__extract_day - , subq_22.created_at__extract_dow - , subq_22.created_at__extract_doy - , subq_22.listing__ds__day - , subq_22.listing__ds__week - , subq_22.listing__ds__month - , subq_22.listing__ds__quarter - , subq_22.listing__ds__year - , subq_22.listing__ds__extract_year - , subq_22.listing__ds__extract_quarter - , subq_22.listing__ds__extract_month - , subq_22.listing__ds__extract_day - , subq_22.listing__ds__extract_dow - , subq_22.listing__ds__extract_doy - , subq_22.listing__created_at__day - , subq_22.listing__created_at__week - , subq_22.listing__created_at__month - , subq_22.listing__created_at__quarter - , subq_22.listing__created_at__year - , subq_22.listing__created_at__extract_year - , subq_22.listing__created_at__extract_quarter - , subq_22.listing__created_at__extract_month - , subq_22.listing__created_at__extract_day - , subq_22.listing__created_at__extract_dow - , subq_22.listing__created_at__extract_doy - , subq_22.ds__day AS metric_time__day - , subq_22.ds__week AS metric_time__week - , subq_22.ds__month AS metric_time__month - , subq_22.ds__quarter AS metric_time__quarter - , subq_22.ds__year AS metric_time__year - , subq_22.ds__extract_year AS metric_time__extract_year - , subq_22.ds__extract_quarter AS metric_time__extract_quarter - , subq_22.ds__extract_month AS metric_time__extract_month - , subq_22.ds__extract_day AS metric_time__extract_day - , subq_22.ds__extract_dow AS metric_time__extract_dow - , subq_22.ds__extract_doy AS metric_time__extract_doy - , subq_22.listing - , subq_22.user - , subq_22.listing__user - , subq_22.country_latest - , subq_22.is_lux_latest - , subq_22.capacity_latest - , subq_22.listing__country_latest - , subq_22.listing__is_lux_latest - , subq_22.listing__capacity_latest - , subq_22.listings - , subq_22.largest_listing - , subq_22.smallest_listing + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.created_at__day + , subq_10.created_at__week + , subq_10.created_at__month + , subq_10.created_at__quarter + , subq_10.created_at__year + , subq_10.created_at__extract_year + , subq_10.created_at__extract_quarter + , subq_10.created_at__extract_month + , subq_10.created_at__extract_day + , subq_10.created_at__extract_dow + , subq_10.created_at__extract_doy + , subq_10.listing__ds__day + , subq_10.listing__ds__week + , subq_10.listing__ds__month + , subq_10.listing__ds__quarter + , subq_10.listing__ds__year + , subq_10.listing__ds__extract_year + , subq_10.listing__ds__extract_quarter + , subq_10.listing__ds__extract_month + , subq_10.listing__ds__extract_day + , subq_10.listing__ds__extract_dow + , subq_10.listing__ds__extract_doy + , subq_10.listing__created_at__day + , subq_10.listing__created_at__week + , subq_10.listing__created_at__month + , subq_10.listing__created_at__quarter + , subq_10.listing__created_at__year + , subq_10.listing__created_at__extract_year + , subq_10.listing__created_at__extract_quarter + , subq_10.listing__created_at__extract_month + , subq_10.listing__created_at__extract_day + , subq_10.listing__created_at__extract_dow + , subq_10.listing__created_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.user + , subq_10.listing__user + , subq_10.country_latest + , subq_10.is_lux_latest + , subq_10.capacity_latest + , subq_10.listing__country_latest + , subq_10.listing__is_lux_latest + , subq_10.listing__capacity_latest + , subq_10.listings + , subq_10.largest_listing + , subq_10.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -482,257 +482,257 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 - ) subq_23 - ) subq_24 + ) subq_10 + ) subq_11 + ) subq_12 ON - subq_21.listing = subq_24.listing - ) subq_25 - ) subq_26 + subq_9.listing = subq_12.listing + ) subq_13 + ) subq_14 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 + ) subq_15 + ) subq_16 + ) subq_17 + ) subq_18 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_42.bookings + subq_30.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_41.bookings) AS bookings + SUM(subq_29.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_40.bookings + subq_28.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_39.booking__is_instant - , subq_39.listing__is_lux_latest - , subq_39.bookings + subq_27.booking__is_instant + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_38.booking__is_instant - , subq_38.listing__is_lux_latest - , subq_38.bookings + subq_26.booking__is_instant + , subq_26.listing__is_lux_latest + , subq_26.bookings FROM ( -- Join Standard Outputs SELECT - subq_34.listing AS listing - , subq_34.booking__is_instant AS booking__is_instant - , subq_37.is_lux_latest AS listing__is_lux_latest - , subq_34.bookings AS bookings + subq_22.listing AS listing + , subq_22.booking__is_instant AS booking__is_instant + , subq_25.is_lux_latest AS listing__is_lux_latest + , subq_22.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_33.listing - , subq_33.booking__is_instant - , subq_33.bookings + subq_21.listing + , subq_21.booking__is_instant + , subq_21.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_32.ds__day - , subq_32.ds__week - , subq_32.ds__month - , subq_32.ds__quarter - , subq_32.ds__year - , subq_32.ds__extract_year - , subq_32.ds__extract_quarter - , subq_32.ds__extract_month - , subq_32.ds__extract_day - , subq_32.ds__extract_dow - , subq_32.ds__extract_doy - , subq_32.ds_partitioned__day - , subq_32.ds_partitioned__week - , subq_32.ds_partitioned__month - , subq_32.ds_partitioned__quarter - , subq_32.ds_partitioned__year - , subq_32.ds_partitioned__extract_year - , subq_32.ds_partitioned__extract_quarter - , subq_32.ds_partitioned__extract_month - , subq_32.ds_partitioned__extract_day - , subq_32.ds_partitioned__extract_dow - , subq_32.ds_partitioned__extract_doy - , subq_32.paid_at__day - , subq_32.paid_at__week - , subq_32.paid_at__month - , subq_32.paid_at__quarter - , subq_32.paid_at__year - , subq_32.paid_at__extract_year - , subq_32.paid_at__extract_quarter - , subq_32.paid_at__extract_month - , subq_32.paid_at__extract_day - , subq_32.paid_at__extract_dow - , subq_32.paid_at__extract_doy - , subq_32.booking__ds__day - , subq_32.booking__ds__week - , subq_32.booking__ds__month - , subq_32.booking__ds__quarter - , subq_32.booking__ds__year - , subq_32.booking__ds__extract_year - , subq_32.booking__ds__extract_quarter - , subq_32.booking__ds__extract_month - , subq_32.booking__ds__extract_day - , subq_32.booking__ds__extract_dow - , subq_32.booking__ds__extract_doy - , subq_32.booking__ds_partitioned__day - , subq_32.booking__ds_partitioned__week - , subq_32.booking__ds_partitioned__month - , subq_32.booking__ds_partitioned__quarter - , subq_32.booking__ds_partitioned__year - , subq_32.booking__ds_partitioned__extract_year - , subq_32.booking__ds_partitioned__extract_quarter - , subq_32.booking__ds_partitioned__extract_month - , subq_32.booking__ds_partitioned__extract_day - , subq_32.booking__ds_partitioned__extract_dow - , subq_32.booking__ds_partitioned__extract_doy - , subq_32.booking__paid_at__day - , subq_32.booking__paid_at__week - , subq_32.booking__paid_at__month - , subq_32.booking__paid_at__quarter - , subq_32.booking__paid_at__year - , subq_32.booking__paid_at__extract_year - , subq_32.booking__paid_at__extract_quarter - , subq_32.booking__paid_at__extract_month - , subq_32.booking__paid_at__extract_day - , subq_32.booking__paid_at__extract_dow - , subq_32.booking__paid_at__extract_doy - , subq_32.metric_time__day - , subq_32.metric_time__week - , subq_32.metric_time__month - , subq_32.metric_time__quarter - , subq_32.metric_time__year - , subq_32.metric_time__extract_year - , subq_32.metric_time__extract_quarter - , subq_32.metric_time__extract_month - , subq_32.metric_time__extract_day - , subq_32.metric_time__extract_dow - , subq_32.metric_time__extract_doy - , subq_32.listing - , subq_32.guest - , subq_32.host - , subq_32.booking__listing - , subq_32.booking__guest - , subq_32.booking__host - , subq_32.is_instant - , subq_32.booking__is_instant - , subq_32.bookings - , subq_32.instant_bookings - , subq_32.booking_value - , subq_32.max_booking_value - , subq_32.min_booking_value - , subq_32.bookers - , subq_32.average_booking_value - , subq_32.referred_bookings - , subq_32.median_booking_value - , subq_32.booking_value_p99 - , subq_32.discrete_booking_value_p99 - , subq_32.approximate_continuous_booking_value_p99 - , subq_32.approximate_discrete_booking_value_p99 + subq_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.metric_time__day + , subq_20.metric_time__week + , subq_20.metric_time__month + , subq_20.metric_time__quarter + , subq_20.metric_time__year + , subq_20.metric_time__extract_year + , subq_20.metric_time__extract_quarter + , subq_20.metric_time__extract_month + , subq_20.metric_time__extract_day + , subq_20.metric_time__extract_dow + , subq_20.metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_31.ds__day - , subq_31.ds__week - , subq_31.ds__month - , subq_31.ds__quarter - , subq_31.ds__year - , subq_31.ds__extract_year - , subq_31.ds__extract_quarter - , subq_31.ds__extract_month - , subq_31.ds__extract_day - , subq_31.ds__extract_dow - , subq_31.ds__extract_doy - , subq_31.ds_partitioned__day - , subq_31.ds_partitioned__week - , subq_31.ds_partitioned__month - , subq_31.ds_partitioned__quarter - , subq_31.ds_partitioned__year - , subq_31.ds_partitioned__extract_year - , subq_31.ds_partitioned__extract_quarter - , subq_31.ds_partitioned__extract_month - , subq_31.ds_partitioned__extract_day - , subq_31.ds_partitioned__extract_dow - , subq_31.ds_partitioned__extract_doy - , subq_31.paid_at__day - , subq_31.paid_at__week - , subq_31.paid_at__month - , subq_31.paid_at__quarter - , subq_31.paid_at__year - , subq_31.paid_at__extract_year - , subq_31.paid_at__extract_quarter - , subq_31.paid_at__extract_month - , subq_31.paid_at__extract_day - , subq_31.paid_at__extract_dow - , subq_31.paid_at__extract_doy - , subq_31.booking__ds__day - , subq_31.booking__ds__week - , subq_31.booking__ds__month - , subq_31.booking__ds__quarter - , subq_31.booking__ds__year - , subq_31.booking__ds__extract_year - , subq_31.booking__ds__extract_quarter - , subq_31.booking__ds__extract_month - , subq_31.booking__ds__extract_day - , subq_31.booking__ds__extract_dow - , subq_31.booking__ds__extract_doy - , subq_31.booking__ds_partitioned__day - , subq_31.booking__ds_partitioned__week - , subq_31.booking__ds_partitioned__month - , subq_31.booking__ds_partitioned__quarter - , subq_31.booking__ds_partitioned__year - , subq_31.booking__ds_partitioned__extract_year - , subq_31.booking__ds_partitioned__extract_quarter - , subq_31.booking__ds_partitioned__extract_month - , subq_31.booking__ds_partitioned__extract_day - , subq_31.booking__ds_partitioned__extract_dow - , subq_31.booking__ds_partitioned__extract_doy - , subq_31.booking__paid_at__day - , subq_31.booking__paid_at__week - , subq_31.booking__paid_at__month - , subq_31.booking__paid_at__quarter - , subq_31.booking__paid_at__year - , subq_31.booking__paid_at__extract_year - , subq_31.booking__paid_at__extract_quarter - , subq_31.booking__paid_at__extract_month - , subq_31.booking__paid_at__extract_day - , subq_31.booking__paid_at__extract_dow - , subq_31.booking__paid_at__extract_doy - , subq_31.ds__day AS metric_time__day - , subq_31.ds__week AS metric_time__week - , subq_31.ds__month AS metric_time__month - , subq_31.ds__quarter AS metric_time__quarter - , subq_31.ds__year AS metric_time__year - , subq_31.ds__extract_year AS metric_time__extract_year - , subq_31.ds__extract_quarter AS metric_time__extract_quarter - , subq_31.ds__extract_month AS metric_time__extract_month - , subq_31.ds__extract_day AS metric_time__extract_day - , subq_31.ds__extract_dow AS metric_time__extract_dow - , subq_31.ds__extract_doy AS metric_time__extract_doy - , subq_31.listing - , subq_31.guest - , subq_31.host - , subq_31.booking__listing - , subq_31.booking__guest - , subq_31.booking__host - , subq_31.is_instant - , subq_31.booking__is_instant - , subq_31.bookings - , subq_31.instant_bookings - , subq_31.booking_value - , subq_31.max_booking_value - , subq_31.min_booking_value - , subq_31.bookers - , subq_31.average_booking_value - , subq_31.referred_bookings - , subq_31.median_booking_value - , subq_31.booking_value_p99 - , subq_31.discrete_booking_value_p99 - , subq_31.approximate_continuous_booking_value_p99 - , subq_31.approximate_discrete_booking_value_p99 + subq_19.ds__day + , subq_19.ds__week + , subq_19.ds__month + , subq_19.ds__quarter + , subq_19.ds__year + , subq_19.ds__extract_year + , subq_19.ds__extract_quarter + , subq_19.ds__extract_month + , subq_19.ds__extract_day + , subq_19.ds__extract_dow + , subq_19.ds__extract_doy + , subq_19.ds_partitioned__day + , subq_19.ds_partitioned__week + , subq_19.ds_partitioned__month + , subq_19.ds_partitioned__quarter + , subq_19.ds_partitioned__year + , subq_19.ds_partitioned__extract_year + , subq_19.ds_partitioned__extract_quarter + , subq_19.ds_partitioned__extract_month + , subq_19.ds_partitioned__extract_day + , subq_19.ds_partitioned__extract_dow + , subq_19.ds_partitioned__extract_doy + , subq_19.paid_at__day + , subq_19.paid_at__week + , subq_19.paid_at__month + , subq_19.paid_at__quarter + , subq_19.paid_at__year + , subq_19.paid_at__extract_year + , subq_19.paid_at__extract_quarter + , subq_19.paid_at__extract_month + , subq_19.paid_at__extract_day + , subq_19.paid_at__extract_dow + , subq_19.paid_at__extract_doy + , subq_19.booking__ds__day + , subq_19.booking__ds__week + , subq_19.booking__ds__month + , subq_19.booking__ds__quarter + , subq_19.booking__ds__year + , subq_19.booking__ds__extract_year + , subq_19.booking__ds__extract_quarter + , subq_19.booking__ds__extract_month + , subq_19.booking__ds__extract_day + , subq_19.booking__ds__extract_dow + , subq_19.booking__ds__extract_doy + , subq_19.booking__ds_partitioned__day + , subq_19.booking__ds_partitioned__week + , subq_19.booking__ds_partitioned__month + , subq_19.booking__ds_partitioned__quarter + , subq_19.booking__ds_partitioned__year + , subq_19.booking__ds_partitioned__extract_year + , subq_19.booking__ds_partitioned__extract_quarter + , subq_19.booking__ds_partitioned__extract_month + , subq_19.booking__ds_partitioned__extract_day + , subq_19.booking__ds_partitioned__extract_dow + , subq_19.booking__ds_partitioned__extract_doy + , subq_19.booking__paid_at__day + , subq_19.booking__paid_at__week + , subq_19.booking__paid_at__month + , subq_19.booking__paid_at__quarter + , subq_19.booking__paid_at__year + , subq_19.booking__paid_at__extract_year + , subq_19.booking__paid_at__extract_quarter + , subq_19.booking__paid_at__extract_month + , subq_19.booking__paid_at__extract_day + , subq_19.booking__paid_at__extract_dow + , subq_19.booking__paid_at__extract_doy + , subq_19.ds__day AS metric_time__day + , subq_19.ds__week AS metric_time__week + , subq_19.ds__month AS metric_time__month + , subq_19.ds__quarter AS metric_time__quarter + , subq_19.ds__year AS metric_time__year + , subq_19.ds__extract_year AS metric_time__extract_year + , subq_19.ds__extract_quarter AS metric_time__extract_quarter + , subq_19.ds__extract_month AS metric_time__extract_month + , subq_19.ds__extract_day AS metric_time__extract_day + , subq_19.ds__extract_dow AS metric_time__extract_dow + , subq_19.ds__extract_doy AS metric_time__extract_doy + , subq_19.listing + , subq_19.guest + , subq_19.host + , subq_19.booking__listing + , subq_19.booking__guest + , subq_19.booking__host + , subq_19.is_instant + , subq_19.booking__is_instant + , subq_19.bookings + , subq_19.instant_bookings + , subq_19.booking_value + , subq_19.max_booking_value + , subq_19.min_booking_value + , subq_19.bookers + , subq_19.average_booking_value + , subq_19.referred_bookings + , subq_19.median_booking_value + , subq_19.booking_value_p99 + , subq_19.discrete_booking_value_p99 + , subq_19.approximate_continuous_booking_value_p99 + , subq_19.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -825,86 +825,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_31 - ) subq_32 + ) subq_19 + ) subq_20 WHERE booking__is_instant - ) subq_33 - ) subq_34 + ) subq_21 + ) subq_22 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_36.listing - , subq_36.is_lux_latest + subq_24.listing + , subq_24.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_35.ds__day - , subq_35.ds__week - , subq_35.ds__month - , subq_35.ds__quarter - , subq_35.ds__year - , subq_35.ds__extract_year - , subq_35.ds__extract_quarter - , subq_35.ds__extract_month - , subq_35.ds__extract_day - , subq_35.ds__extract_dow - , subq_35.ds__extract_doy - , subq_35.created_at__day - , subq_35.created_at__week - , subq_35.created_at__month - , subq_35.created_at__quarter - , subq_35.created_at__year - , subq_35.created_at__extract_year - , subq_35.created_at__extract_quarter - , subq_35.created_at__extract_month - , subq_35.created_at__extract_day - , subq_35.created_at__extract_dow - , subq_35.created_at__extract_doy - , subq_35.listing__ds__day - , subq_35.listing__ds__week - , subq_35.listing__ds__month - , subq_35.listing__ds__quarter - , subq_35.listing__ds__year - , subq_35.listing__ds__extract_year - , subq_35.listing__ds__extract_quarter - , subq_35.listing__ds__extract_month - , subq_35.listing__ds__extract_day - , subq_35.listing__ds__extract_dow - , subq_35.listing__ds__extract_doy - , subq_35.listing__created_at__day - , subq_35.listing__created_at__week - , subq_35.listing__created_at__month - , subq_35.listing__created_at__quarter - , subq_35.listing__created_at__year - , subq_35.listing__created_at__extract_year - , subq_35.listing__created_at__extract_quarter - , subq_35.listing__created_at__extract_month - , subq_35.listing__created_at__extract_day - , subq_35.listing__created_at__extract_dow - , subq_35.listing__created_at__extract_doy - , subq_35.ds__day AS metric_time__day - , subq_35.ds__week AS metric_time__week - , subq_35.ds__month AS metric_time__month - , subq_35.ds__quarter AS metric_time__quarter - , subq_35.ds__year AS metric_time__year - , subq_35.ds__extract_year AS metric_time__extract_year - , subq_35.ds__extract_quarter AS metric_time__extract_quarter - , subq_35.ds__extract_month AS metric_time__extract_month - , subq_35.ds__extract_day AS metric_time__extract_day - , subq_35.ds__extract_dow AS metric_time__extract_dow - , subq_35.ds__extract_doy AS metric_time__extract_doy - , subq_35.listing - , subq_35.user - , subq_35.listing__user - , subq_35.country_latest - , subq_35.is_lux_latest - , subq_35.capacity_latest - , subq_35.listing__country_latest - , subq_35.listing__is_lux_latest - , subq_35.listing__capacity_latest - , subq_35.listings - , subq_35.largest_listing - , subq_35.smallest_listing + subq_23.ds__day + , subq_23.ds__week + , subq_23.ds__month + , subq_23.ds__quarter + , subq_23.ds__year + , subq_23.ds__extract_year + , subq_23.ds__extract_quarter + , subq_23.ds__extract_month + , subq_23.ds__extract_day + , subq_23.ds__extract_dow + , subq_23.ds__extract_doy + , subq_23.created_at__day + , subq_23.created_at__week + , subq_23.created_at__month + , subq_23.created_at__quarter + , subq_23.created_at__year + , subq_23.created_at__extract_year + , subq_23.created_at__extract_quarter + , subq_23.created_at__extract_month + , subq_23.created_at__extract_day + , subq_23.created_at__extract_dow + , subq_23.created_at__extract_doy + , subq_23.listing__ds__day + , subq_23.listing__ds__week + , subq_23.listing__ds__month + , subq_23.listing__ds__quarter + , subq_23.listing__ds__year + , subq_23.listing__ds__extract_year + , subq_23.listing__ds__extract_quarter + , subq_23.listing__ds__extract_month + , subq_23.listing__ds__extract_day + , subq_23.listing__ds__extract_dow + , subq_23.listing__ds__extract_doy + , subq_23.listing__created_at__day + , subq_23.listing__created_at__week + , subq_23.listing__created_at__month + , subq_23.listing__created_at__quarter + , subq_23.listing__created_at__year + , subq_23.listing__created_at__extract_year + , subq_23.listing__created_at__extract_quarter + , subq_23.listing__created_at__extract_month + , subq_23.listing__created_at__extract_day + , subq_23.listing__created_at__extract_dow + , subq_23.listing__created_at__extract_doy + , subq_23.ds__day AS metric_time__day + , subq_23.ds__week AS metric_time__week + , subq_23.ds__month AS metric_time__month + , subq_23.ds__quarter AS metric_time__quarter + , subq_23.ds__year AS metric_time__year + , subq_23.ds__extract_year AS metric_time__extract_year + , subq_23.ds__extract_quarter AS metric_time__extract_quarter + , subq_23.ds__extract_month AS metric_time__extract_month + , subq_23.ds__extract_day AS metric_time__extract_day + , subq_23.ds__extract_dow AS metric_time__extract_dow + , subq_23.ds__extract_doy AS metric_time__extract_doy + , subq_23.listing + , subq_23.user + , subq_23.listing__user + , subq_23.country_latest + , subq_23.is_lux_latest + , subq_23.capacity_latest + , subq_23.listing__country_latest + , subq_23.listing__is_lux_latest + , subq_23.listing__capacity_latest + , subq_23.listings + , subq_23.largest_listing + , subq_23.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -965,242 +965,242 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_35 - ) subq_36 - ) subq_37 + ) subq_23 + ) subq_24 + ) subq_25 ON - subq_34.listing = subq_37.listing - ) subq_38 - ) subq_39 + subq_22.listing = subq_25.listing + ) subq_26 + ) subq_27 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_40 - ) subq_41 - ) subq_42 - ) subq_43 + ) subq_28 + ) subq_29 + ) subq_30 + ) subq_31 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_50.booking_value + subq_38.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_49.booking_value) AS booking_value + SUM(subq_37.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_48.booking_value + subq_36.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_47.booking__is_instant - , subq_47.booking_value + subq_35.booking__is_instant + , subq_35.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_46.booking__is_instant - , subq_46.booking_value + subq_34.booking__is_instant + , subq_34.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_45.ds__day - , subq_45.ds__week - , subq_45.ds__month - , subq_45.ds__quarter - , subq_45.ds__year - , subq_45.ds__extract_year - , subq_45.ds__extract_quarter - , subq_45.ds__extract_month - , subq_45.ds__extract_day - , subq_45.ds__extract_dow - , subq_45.ds__extract_doy - , subq_45.ds_partitioned__day - , subq_45.ds_partitioned__week - , subq_45.ds_partitioned__month - , subq_45.ds_partitioned__quarter - , subq_45.ds_partitioned__year - , subq_45.ds_partitioned__extract_year - , subq_45.ds_partitioned__extract_quarter - , subq_45.ds_partitioned__extract_month - , subq_45.ds_partitioned__extract_day - , subq_45.ds_partitioned__extract_dow - , subq_45.ds_partitioned__extract_doy - , subq_45.paid_at__day - , subq_45.paid_at__week - , subq_45.paid_at__month - , subq_45.paid_at__quarter - , subq_45.paid_at__year - , subq_45.paid_at__extract_year - , subq_45.paid_at__extract_quarter - , subq_45.paid_at__extract_month - , subq_45.paid_at__extract_day - , subq_45.paid_at__extract_dow - , subq_45.paid_at__extract_doy - , subq_45.booking__ds__day - , subq_45.booking__ds__week - , subq_45.booking__ds__month - , subq_45.booking__ds__quarter - , subq_45.booking__ds__year - , subq_45.booking__ds__extract_year - , subq_45.booking__ds__extract_quarter - , subq_45.booking__ds__extract_month - , subq_45.booking__ds__extract_day - , subq_45.booking__ds__extract_dow - , subq_45.booking__ds__extract_doy - , subq_45.booking__ds_partitioned__day - , subq_45.booking__ds_partitioned__week - , subq_45.booking__ds_partitioned__month - , subq_45.booking__ds_partitioned__quarter - , subq_45.booking__ds_partitioned__year - , subq_45.booking__ds_partitioned__extract_year - , subq_45.booking__ds_partitioned__extract_quarter - , subq_45.booking__ds_partitioned__extract_month - , subq_45.booking__ds_partitioned__extract_day - , subq_45.booking__ds_partitioned__extract_dow - , subq_45.booking__ds_partitioned__extract_doy - , subq_45.booking__paid_at__day - , subq_45.booking__paid_at__week - , subq_45.booking__paid_at__month - , subq_45.booking__paid_at__quarter - , subq_45.booking__paid_at__year - , subq_45.booking__paid_at__extract_year - , subq_45.booking__paid_at__extract_quarter - , subq_45.booking__paid_at__extract_month - , subq_45.booking__paid_at__extract_day - , subq_45.booking__paid_at__extract_dow - , subq_45.booking__paid_at__extract_doy - , subq_45.metric_time__day - , subq_45.metric_time__week - , subq_45.metric_time__month - , subq_45.metric_time__quarter - , subq_45.metric_time__year - , subq_45.metric_time__extract_year - , subq_45.metric_time__extract_quarter - , subq_45.metric_time__extract_month - , subq_45.metric_time__extract_day - , subq_45.metric_time__extract_dow - , subq_45.metric_time__extract_doy - , subq_45.listing - , subq_45.guest - , subq_45.host - , subq_45.booking__listing - , subq_45.booking__guest - , subq_45.booking__host - , subq_45.is_instant - , subq_45.booking__is_instant - , subq_45.bookings - , subq_45.instant_bookings - , subq_45.booking_value - , subq_45.max_booking_value - , subq_45.min_booking_value - , subq_45.bookers - , subq_45.average_booking_value - , subq_45.referred_bookings - , subq_45.median_booking_value - , subq_45.booking_value_p99 - , subq_45.discrete_booking_value_p99 - , subq_45.approximate_continuous_booking_value_p99 - , subq_45.approximate_discrete_booking_value_p99 + subq_33.ds__day + , subq_33.ds__week + , subq_33.ds__month + , subq_33.ds__quarter + , subq_33.ds__year + , subq_33.ds__extract_year + , subq_33.ds__extract_quarter + , subq_33.ds__extract_month + , subq_33.ds__extract_day + , subq_33.ds__extract_dow + , subq_33.ds__extract_doy + , subq_33.ds_partitioned__day + , subq_33.ds_partitioned__week + , subq_33.ds_partitioned__month + , subq_33.ds_partitioned__quarter + , subq_33.ds_partitioned__year + , subq_33.ds_partitioned__extract_year + , subq_33.ds_partitioned__extract_quarter + , subq_33.ds_partitioned__extract_month + , subq_33.ds_partitioned__extract_day + , subq_33.ds_partitioned__extract_dow + , subq_33.ds_partitioned__extract_doy + , subq_33.paid_at__day + , subq_33.paid_at__week + , subq_33.paid_at__month + , subq_33.paid_at__quarter + , subq_33.paid_at__year + , subq_33.paid_at__extract_year + , subq_33.paid_at__extract_quarter + , subq_33.paid_at__extract_month + , subq_33.paid_at__extract_day + , subq_33.paid_at__extract_dow + , subq_33.paid_at__extract_doy + , subq_33.booking__ds__day + , subq_33.booking__ds__week + , subq_33.booking__ds__month + , subq_33.booking__ds__quarter + , subq_33.booking__ds__year + , subq_33.booking__ds__extract_year + , subq_33.booking__ds__extract_quarter + , subq_33.booking__ds__extract_month + , subq_33.booking__ds__extract_day + , subq_33.booking__ds__extract_dow + , subq_33.booking__ds__extract_doy + , subq_33.booking__ds_partitioned__day + , subq_33.booking__ds_partitioned__week + , subq_33.booking__ds_partitioned__month + , subq_33.booking__ds_partitioned__quarter + , subq_33.booking__ds_partitioned__year + , subq_33.booking__ds_partitioned__extract_year + , subq_33.booking__ds_partitioned__extract_quarter + , subq_33.booking__ds_partitioned__extract_month + , subq_33.booking__ds_partitioned__extract_day + , subq_33.booking__ds_partitioned__extract_dow + , subq_33.booking__ds_partitioned__extract_doy + , subq_33.booking__paid_at__day + , subq_33.booking__paid_at__week + , subq_33.booking__paid_at__month + , subq_33.booking__paid_at__quarter + , subq_33.booking__paid_at__year + , subq_33.booking__paid_at__extract_year + , subq_33.booking__paid_at__extract_quarter + , subq_33.booking__paid_at__extract_month + , subq_33.booking__paid_at__extract_day + , subq_33.booking__paid_at__extract_dow + , subq_33.booking__paid_at__extract_doy + , subq_33.metric_time__day + , subq_33.metric_time__week + , subq_33.metric_time__month + , subq_33.metric_time__quarter + , subq_33.metric_time__year + , subq_33.metric_time__extract_year + , subq_33.metric_time__extract_quarter + , subq_33.metric_time__extract_month + , subq_33.metric_time__extract_day + , subq_33.metric_time__extract_dow + , subq_33.metric_time__extract_doy + , subq_33.listing + , subq_33.guest + , subq_33.host + , subq_33.booking__listing + , subq_33.booking__guest + , subq_33.booking__host + , subq_33.is_instant + , subq_33.booking__is_instant + , subq_33.bookings + , subq_33.instant_bookings + , subq_33.booking_value + , subq_33.max_booking_value + , subq_33.min_booking_value + , subq_33.bookers + , subq_33.average_booking_value + , subq_33.referred_bookings + , subq_33.median_booking_value + , subq_33.booking_value_p99 + , subq_33.discrete_booking_value_p99 + , subq_33.approximate_continuous_booking_value_p99 + , subq_33.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_44.ds__day - , subq_44.ds__week - , subq_44.ds__month - , subq_44.ds__quarter - , subq_44.ds__year - , subq_44.ds__extract_year - , subq_44.ds__extract_quarter - , subq_44.ds__extract_month - , subq_44.ds__extract_day - , subq_44.ds__extract_dow - , subq_44.ds__extract_doy - , subq_44.ds_partitioned__day - , subq_44.ds_partitioned__week - , subq_44.ds_partitioned__month - , subq_44.ds_partitioned__quarter - , subq_44.ds_partitioned__year - , subq_44.ds_partitioned__extract_year - , subq_44.ds_partitioned__extract_quarter - , subq_44.ds_partitioned__extract_month - , subq_44.ds_partitioned__extract_day - , subq_44.ds_partitioned__extract_dow - , subq_44.ds_partitioned__extract_doy - , subq_44.paid_at__day - , subq_44.paid_at__week - , subq_44.paid_at__month - , subq_44.paid_at__quarter - , subq_44.paid_at__year - , subq_44.paid_at__extract_year - , subq_44.paid_at__extract_quarter - , subq_44.paid_at__extract_month - , subq_44.paid_at__extract_day - , subq_44.paid_at__extract_dow - , subq_44.paid_at__extract_doy - , subq_44.booking__ds__day - , subq_44.booking__ds__week - , subq_44.booking__ds__month - , subq_44.booking__ds__quarter - , subq_44.booking__ds__year - , subq_44.booking__ds__extract_year - , subq_44.booking__ds__extract_quarter - , subq_44.booking__ds__extract_month - , subq_44.booking__ds__extract_day - , subq_44.booking__ds__extract_dow - , subq_44.booking__ds__extract_doy - , subq_44.booking__ds_partitioned__day - , subq_44.booking__ds_partitioned__week - , subq_44.booking__ds_partitioned__month - , subq_44.booking__ds_partitioned__quarter - , subq_44.booking__ds_partitioned__year - , subq_44.booking__ds_partitioned__extract_year - , subq_44.booking__ds_partitioned__extract_quarter - , subq_44.booking__ds_partitioned__extract_month - , subq_44.booking__ds_partitioned__extract_day - , subq_44.booking__ds_partitioned__extract_dow - , subq_44.booking__ds_partitioned__extract_doy - , subq_44.booking__paid_at__day - , subq_44.booking__paid_at__week - , subq_44.booking__paid_at__month - , subq_44.booking__paid_at__quarter - , subq_44.booking__paid_at__year - , subq_44.booking__paid_at__extract_year - , subq_44.booking__paid_at__extract_quarter - , subq_44.booking__paid_at__extract_month - , subq_44.booking__paid_at__extract_day - , subq_44.booking__paid_at__extract_dow - , subq_44.booking__paid_at__extract_doy - , subq_44.ds__day AS metric_time__day - , subq_44.ds__week AS metric_time__week - , subq_44.ds__month AS metric_time__month - , subq_44.ds__quarter AS metric_time__quarter - , subq_44.ds__year AS metric_time__year - , subq_44.ds__extract_year AS metric_time__extract_year - , subq_44.ds__extract_quarter AS metric_time__extract_quarter - , subq_44.ds__extract_month AS metric_time__extract_month - , subq_44.ds__extract_day AS metric_time__extract_day - , subq_44.ds__extract_dow AS metric_time__extract_dow - , subq_44.ds__extract_doy AS metric_time__extract_doy - , subq_44.listing - , subq_44.guest - , subq_44.host - , subq_44.booking__listing - , subq_44.booking__guest - , subq_44.booking__host - , subq_44.is_instant - , subq_44.booking__is_instant - , subq_44.bookings - , subq_44.instant_bookings - , subq_44.booking_value - , subq_44.max_booking_value - , subq_44.min_booking_value - , subq_44.bookers - , subq_44.average_booking_value - , subq_44.referred_bookings - , subq_44.median_booking_value - , subq_44.booking_value_p99 - , subq_44.discrete_booking_value_p99 - , subq_44.approximate_continuous_booking_value_p99 - , subq_44.approximate_discrete_booking_value_p99 + subq_32.ds__day + , subq_32.ds__week + , subq_32.ds__month + , subq_32.ds__quarter + , subq_32.ds__year + , subq_32.ds__extract_year + , subq_32.ds__extract_quarter + , subq_32.ds__extract_month + , subq_32.ds__extract_day + , subq_32.ds__extract_dow + , subq_32.ds__extract_doy + , subq_32.ds_partitioned__day + , subq_32.ds_partitioned__week + , subq_32.ds_partitioned__month + , subq_32.ds_partitioned__quarter + , subq_32.ds_partitioned__year + , subq_32.ds_partitioned__extract_year + , subq_32.ds_partitioned__extract_quarter + , subq_32.ds_partitioned__extract_month + , subq_32.ds_partitioned__extract_day + , subq_32.ds_partitioned__extract_dow + , subq_32.ds_partitioned__extract_doy + , subq_32.paid_at__day + , subq_32.paid_at__week + , subq_32.paid_at__month + , subq_32.paid_at__quarter + , subq_32.paid_at__year + , subq_32.paid_at__extract_year + , subq_32.paid_at__extract_quarter + , subq_32.paid_at__extract_month + , subq_32.paid_at__extract_day + , subq_32.paid_at__extract_dow + , subq_32.paid_at__extract_doy + , subq_32.booking__ds__day + , subq_32.booking__ds__week + , subq_32.booking__ds__month + , subq_32.booking__ds__quarter + , subq_32.booking__ds__year + , subq_32.booking__ds__extract_year + , subq_32.booking__ds__extract_quarter + , subq_32.booking__ds__extract_month + , subq_32.booking__ds__extract_day + , subq_32.booking__ds__extract_dow + , subq_32.booking__ds__extract_doy + , subq_32.booking__ds_partitioned__day + , subq_32.booking__ds_partitioned__week + , subq_32.booking__ds_partitioned__month + , subq_32.booking__ds_partitioned__quarter + , subq_32.booking__ds_partitioned__year + , subq_32.booking__ds_partitioned__extract_year + , subq_32.booking__ds_partitioned__extract_quarter + , subq_32.booking__ds_partitioned__extract_month + , subq_32.booking__ds_partitioned__extract_day + , subq_32.booking__ds_partitioned__extract_dow + , subq_32.booking__ds_partitioned__extract_doy + , subq_32.booking__paid_at__day + , subq_32.booking__paid_at__week + , subq_32.booking__paid_at__month + , subq_32.booking__paid_at__quarter + , subq_32.booking__paid_at__year + , subq_32.booking__paid_at__extract_year + , subq_32.booking__paid_at__extract_quarter + , subq_32.booking__paid_at__extract_month + , subq_32.booking__paid_at__extract_day + , subq_32.booking__paid_at__extract_dow + , subq_32.booking__paid_at__extract_doy + , subq_32.ds__day AS metric_time__day + , subq_32.ds__week AS metric_time__week + , subq_32.ds__month AS metric_time__month + , subq_32.ds__quarter AS metric_time__quarter + , subq_32.ds__year AS metric_time__year + , subq_32.ds__extract_year AS metric_time__extract_year + , subq_32.ds__extract_quarter AS metric_time__extract_quarter + , subq_32.ds__extract_month AS metric_time__extract_month + , subq_32.ds__extract_day AS metric_time__extract_day + , subq_32.ds__extract_dow AS metric_time__extract_dow + , subq_32.ds__extract_doy AS metric_time__extract_doy + , subq_32.listing + , subq_32.guest + , subq_32.host + , subq_32.booking__listing + , subq_32.booking__guest + , subq_32.booking__host + , subq_32.is_instant + , subq_32.booking__is_instant + , subq_32.bookings + , subq_32.instant_bookings + , subq_32.booking_value + , subq_32.max_booking_value + , subq_32.min_booking_value + , subq_32.bookers + , subq_32.average_booking_value + , subq_32.referred_bookings + , subq_32.median_booking_value + , subq_32.booking_value_p99 + , subq_32.discrete_booking_value_p99 + , subq_32.approximate_continuous_booking_value_p99 + , subq_32.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -1293,15 +1293,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_44 - ) subq_45 + ) subq_32 + ) subq_33 WHERE booking__is_instant - ) subq_46 - ) subq_47 + ) subq_34 + ) subq_35 WHERE booking__is_instant - ) subq_48 - ) subq_49 - ) subq_50 - ) subq_51 - ) subq_52 -) subq_53 + ) subq_36 + ) subq_37 + ) subq_38 + ) subq_39 + ) subq_40 +) subq_41 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/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 a0fdc735bd..60a09b752b 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_66.average_booking_value) AS average_booking_value - , MAX(subq_79.bookings) AS bookings - , MAX(subq_87.booking_value) AS booking_value + MAX(subq_54.average_booking_value) AS average_booking_value + , MAX(subq_67.bookings) AS bookings + , MAX(subq_75.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value',] @@ -22,9 +22,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_57.booking__is_instant AS booking__is_instant + subq_45.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_57.average_booking_value AS average_booking_value + , subq_45.average_booking_value AS average_booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] @@ -40,16 +40,16 @@ FROM ( , is_instant AS booking__is_instant , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_55 + ) subq_43 WHERE booking__is_instant - ) subq_57 + ) subq_45 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_57.listing = listings_latest_src_28000.listing_id - ) subq_62 + subq_45.listing = listings_latest_src_28000.listing_id + ) subq_50 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_66 + ) subq_54 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings',] @@ -61,9 +61,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_70.booking__is_instant AS booking__is_instant + subq_58.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_70.bookings AS bookings + , subq_58.bookings AS bookings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] @@ -79,16 +79,16 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_68 + ) subq_56 WHERE booking__is_instant - ) subq_70 + ) subq_58 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_70.listing = listings_latest_src_28000.listing_id - ) subq_75 + subq_58.listing = listings_latest_src_28000.listing_id + ) subq_63 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_79 + ) subq_67 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -109,10 +109,10 @@ FROM ( is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_81 + ) subq_69 WHERE booking__is_instant - ) subq_83 + ) subq_71 WHERE booking__is_instant - ) subq_87 - ) subq_88 -) subq_89 + ) subq_75 + ) subq_76 +) subq_77 diff --git a/tests_metricflow/snapshots/test_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 bc02f3bba4..dfcc81fb82 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_30.average_booking_value) AS average_booking_value - , MAX(subq_43.bookings) AS bookings - , MAX(subq_51.booking_value) AS booking_value + MAX(subq_18.average_booking_value) AS average_booking_value + , MAX(subq_31.bookings) AS bookings + , MAX(subq_39.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_29.average_booking_value + subq_17.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_28.average_booking_value) AS average_booking_value + AVG(subq_16.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_27.average_booking_value + subq_15.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.listing__is_lux_latest - , subq_26.average_booking_value + subq_14.booking__is_instant + , subq_14.listing__is_lux_latest + , subq_14.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_25.booking__is_instant - , subq_25.listing__is_lux_latest - , subq_25.average_booking_value + subq_13.booking__is_instant + , subq_13.listing__is_lux_latest + , subq_13.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_21.listing AS listing - , subq_21.booking__is_instant AS booking__is_instant - , subq_24.is_lux_latest AS listing__is_lux_latest - , subq_21.average_booking_value AS average_booking_value + subq_9.listing AS listing + , subq_9.booking__is_instant AS booking__is_instant + , subq_12.is_lux_latest AS listing__is_lux_latest + , subq_9.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_20.listing - , subq_20.booking__is_instant - , subq_20.average_booking_value + subq_8.listing + , subq_8.booking__is_instant + , subq_8.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_19.ds__day - , subq_19.ds__week - , subq_19.ds__month - , subq_19.ds__quarter - , subq_19.ds__year - , subq_19.ds__extract_year - , subq_19.ds__extract_quarter - , subq_19.ds__extract_month - , subq_19.ds__extract_day - , subq_19.ds__extract_dow - , subq_19.ds__extract_doy - , subq_19.ds_partitioned__day - , subq_19.ds_partitioned__week - , subq_19.ds_partitioned__month - , subq_19.ds_partitioned__quarter - , subq_19.ds_partitioned__year - , subq_19.ds_partitioned__extract_year - , subq_19.ds_partitioned__extract_quarter - , subq_19.ds_partitioned__extract_month - , subq_19.ds_partitioned__extract_day - , subq_19.ds_partitioned__extract_dow - , subq_19.ds_partitioned__extract_doy - , subq_19.paid_at__day - , subq_19.paid_at__week - , subq_19.paid_at__month - , subq_19.paid_at__quarter - , subq_19.paid_at__year - , subq_19.paid_at__extract_year - , subq_19.paid_at__extract_quarter - , subq_19.paid_at__extract_month - , subq_19.paid_at__extract_day - , subq_19.paid_at__extract_dow - , subq_19.paid_at__extract_doy - , subq_19.booking__ds__day - , subq_19.booking__ds__week - , subq_19.booking__ds__month - , subq_19.booking__ds__quarter - , subq_19.booking__ds__year - , subq_19.booking__ds__extract_year - , subq_19.booking__ds__extract_quarter - , subq_19.booking__ds__extract_month - , subq_19.booking__ds__extract_day - , subq_19.booking__ds__extract_dow - , subq_19.booking__ds__extract_doy - , subq_19.booking__ds_partitioned__day - , subq_19.booking__ds_partitioned__week - , subq_19.booking__ds_partitioned__month - , subq_19.booking__ds_partitioned__quarter - , subq_19.booking__ds_partitioned__year - , subq_19.booking__ds_partitioned__extract_year - , subq_19.booking__ds_partitioned__extract_quarter - , subq_19.booking__ds_partitioned__extract_month - , subq_19.booking__ds_partitioned__extract_day - , subq_19.booking__ds_partitioned__extract_dow - , subq_19.booking__ds_partitioned__extract_doy - , subq_19.booking__paid_at__day - , subq_19.booking__paid_at__week - , subq_19.booking__paid_at__month - , subq_19.booking__paid_at__quarter - , subq_19.booking__paid_at__year - , subq_19.booking__paid_at__extract_year - , subq_19.booking__paid_at__extract_quarter - , subq_19.booking__paid_at__extract_month - , subq_19.booking__paid_at__extract_day - , subq_19.booking__paid_at__extract_dow - , subq_19.booking__paid_at__extract_doy - , subq_19.metric_time__day - , subq_19.metric_time__week - , subq_19.metric_time__month - , subq_19.metric_time__quarter - , subq_19.metric_time__year - , subq_19.metric_time__extract_year - , subq_19.metric_time__extract_quarter - , subq_19.metric_time__extract_month - , subq_19.metric_time__extract_day - , subq_19.metric_time__extract_dow - , subq_19.metric_time__extract_doy - , subq_19.listing - , subq_19.guest - , subq_19.host - , subq_19.booking__listing - , subq_19.booking__guest - , subq_19.booking__host - , subq_19.is_instant - , subq_19.booking__is_instant - , subq_19.bookings - , subq_19.instant_bookings - , subq_19.booking_value - , subq_19.max_booking_value - , subq_19.min_booking_value - , subq_19.bookers - , subq_19.average_booking_value - , subq_19.referred_bookings - , subq_19.median_booking_value - , subq_19.booking_value_p99 - , subq_19.discrete_booking_value_p99 - , subq_19.approximate_continuous_booking_value_p99 - , subq_19.approximate_discrete_booking_value_p99 + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.ds_partitioned__day + , subq_7.ds_partitioned__week + , subq_7.ds_partitioned__month + , subq_7.ds_partitioned__quarter + , subq_7.ds_partitioned__year + , subq_7.ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy + , subq_7.paid_at__day + , subq_7.paid_at__week + , subq_7.paid_at__month + , subq_7.paid_at__quarter + , subq_7.paid_at__year + , subq_7.paid_at__extract_year + , subq_7.paid_at__extract_quarter + , subq_7.paid_at__extract_month + , subq_7.paid_at__extract_day + , subq_7.paid_at__extract_dow + , subq_7.paid_at__extract_doy + , subq_7.booking__ds__day + , subq_7.booking__ds__week + , subq_7.booking__ds__month + , subq_7.booking__ds__quarter + , subq_7.booking__ds__year + , subq_7.booking__ds__extract_year + , subq_7.booking__ds__extract_quarter + , subq_7.booking__ds__extract_month + , subq_7.booking__ds__extract_day + , subq_7.booking__ds__extract_dow + , subq_7.booking__ds__extract_doy + , subq_7.booking__ds_partitioned__day + , subq_7.booking__ds_partitioned__week + , subq_7.booking__ds_partitioned__month + , subq_7.booking__ds_partitioned__quarter + , subq_7.booking__ds_partitioned__year + , subq_7.booking__ds_partitioned__extract_year + , subq_7.booking__ds_partitioned__extract_quarter + , subq_7.booking__ds_partitioned__extract_month + , subq_7.booking__ds_partitioned__extract_day + , subq_7.booking__ds_partitioned__extract_dow + , subq_7.booking__ds_partitioned__extract_doy + , subq_7.booking__paid_at__day + , subq_7.booking__paid_at__week + , subq_7.booking__paid_at__month + , subq_7.booking__paid_at__quarter + , subq_7.booking__paid_at__year + , subq_7.booking__paid_at__extract_year + , subq_7.booking__paid_at__extract_quarter + , subq_7.booking__paid_at__extract_month + , subq_7.booking__paid_at__extract_day + , subq_7.booking__paid_at__extract_dow + , subq_7.booking__paid_at__extract_doy + , subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.metric_time__month + , subq_7.metric_time__quarter + , subq_7.metric_time__year + , subq_7.metric_time__extract_year + , subq_7.metric_time__extract_quarter + , subq_7.metric_time__extract_month + , subq_7.metric_time__extract_day + , subq_7.metric_time__extract_dow + , subq_7.metric_time__extract_doy + , subq_7.listing + , subq_7.guest + , subq_7.host + , subq_7.booking__listing + , subq_7.booking__guest + , subq_7.booking__host + , subq_7.is_instant + , subq_7.booking__is_instant + , subq_7.bookings + , subq_7.instant_bookings + , subq_7.booking_value + , subq_7.max_booking_value + , subq_7.min_booking_value + , subq_7.bookers + , subq_7.average_booking_value + , subq_7.referred_bookings + , subq_7.median_booking_value + , subq_7.booking_value_p99 + , subq_7.discrete_booking_value_p99 + , subq_7.approximate_continuous_booking_value_p99 + , subq_7.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.ds_partitioned__day - , subq_18.ds_partitioned__week - , subq_18.ds_partitioned__month - , subq_18.ds_partitioned__quarter - , subq_18.ds_partitioned__year - , subq_18.ds_partitioned__extract_year - , subq_18.ds_partitioned__extract_quarter - , subq_18.ds_partitioned__extract_month - , subq_18.ds_partitioned__extract_day - , subq_18.ds_partitioned__extract_dow - , subq_18.ds_partitioned__extract_doy - , subq_18.paid_at__day - , subq_18.paid_at__week - , subq_18.paid_at__month - , subq_18.paid_at__quarter - , subq_18.paid_at__year - , subq_18.paid_at__extract_year - , subq_18.paid_at__extract_quarter - , subq_18.paid_at__extract_month - , subq_18.paid_at__extract_day - , subq_18.paid_at__extract_dow - , subq_18.paid_at__extract_doy - , subq_18.booking__ds__day - , subq_18.booking__ds__week - , subq_18.booking__ds__month - , subq_18.booking__ds__quarter - , subq_18.booking__ds__year - , subq_18.booking__ds__extract_year - , subq_18.booking__ds__extract_quarter - , subq_18.booking__ds__extract_month - , subq_18.booking__ds__extract_day - , subq_18.booking__ds__extract_dow - , subq_18.booking__ds__extract_doy - , subq_18.booking__ds_partitioned__day - , subq_18.booking__ds_partitioned__week - , subq_18.booking__ds_partitioned__month - , subq_18.booking__ds_partitioned__quarter - , subq_18.booking__ds_partitioned__year - , subq_18.booking__ds_partitioned__extract_year - , subq_18.booking__ds_partitioned__extract_quarter - , subq_18.booking__ds_partitioned__extract_month - , subq_18.booking__ds_partitioned__extract_day - , subq_18.booking__ds_partitioned__extract_dow - , subq_18.booking__ds_partitioned__extract_doy - , subq_18.booking__paid_at__day - , subq_18.booking__paid_at__week - , subq_18.booking__paid_at__month - , subq_18.booking__paid_at__quarter - , subq_18.booking__paid_at__year - , subq_18.booking__paid_at__extract_year - , subq_18.booking__paid_at__extract_quarter - , subq_18.booking__paid_at__extract_month - , subq_18.booking__paid_at__extract_day - , subq_18.booking__paid_at__extract_dow - , subq_18.booking__paid_at__extract_doy - , subq_18.ds__day AS metric_time__day - , subq_18.ds__week AS metric_time__week - , subq_18.ds__month AS metric_time__month - , subq_18.ds__quarter AS metric_time__quarter - , subq_18.ds__year AS metric_time__year - , subq_18.ds__extract_year AS metric_time__extract_year - , subq_18.ds__extract_quarter AS metric_time__extract_quarter - , subq_18.ds__extract_month AS metric_time__extract_month - , subq_18.ds__extract_day AS metric_time__extract_day - , subq_18.ds__extract_dow AS metric_time__extract_dow - , subq_18.ds__extract_doy AS metric_time__extract_doy - , subq_18.listing - , subq_18.guest - , subq_18.host - , subq_18.booking__listing - , subq_18.booking__guest - , subq_18.booking__host - , subq_18.is_instant - , subq_18.booking__is_instant - , subq_18.bookings - , subq_18.instant_bookings - , subq_18.booking_value - , subq_18.max_booking_value - , subq_18.min_booking_value - , subq_18.bookers - , subq_18.average_booking_value - , subq_18.referred_bookings - , subq_18.median_booking_value - , subq_18.booking_value_p99 - , subq_18.discrete_booking_value_p99 - , subq_18.approximate_continuous_booking_value_p99 - , subq_18.approximate_discrete_booking_value_p99 + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -342,86 +342,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_18 - ) subq_19 + ) subq_6 + ) subq_7 WHERE booking__is_instant - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_23.listing - , subq_23.is_lux_latest + subq_11.listing + , subq_11.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_22.ds__day - , subq_22.ds__week - , subq_22.ds__month - , subq_22.ds__quarter - , subq_22.ds__year - , subq_22.ds__extract_year - , subq_22.ds__extract_quarter - , subq_22.ds__extract_month - , subq_22.ds__extract_day - , subq_22.ds__extract_dow - , subq_22.ds__extract_doy - , subq_22.created_at__day - , subq_22.created_at__week - , subq_22.created_at__month - , subq_22.created_at__quarter - , subq_22.created_at__year - , subq_22.created_at__extract_year - , subq_22.created_at__extract_quarter - , subq_22.created_at__extract_month - , subq_22.created_at__extract_day - , subq_22.created_at__extract_dow - , subq_22.created_at__extract_doy - , subq_22.listing__ds__day - , subq_22.listing__ds__week - , subq_22.listing__ds__month - , subq_22.listing__ds__quarter - , subq_22.listing__ds__year - , subq_22.listing__ds__extract_year - , subq_22.listing__ds__extract_quarter - , subq_22.listing__ds__extract_month - , subq_22.listing__ds__extract_day - , subq_22.listing__ds__extract_dow - , subq_22.listing__ds__extract_doy - , subq_22.listing__created_at__day - , subq_22.listing__created_at__week - , subq_22.listing__created_at__month - , subq_22.listing__created_at__quarter - , subq_22.listing__created_at__year - , subq_22.listing__created_at__extract_year - , subq_22.listing__created_at__extract_quarter - , subq_22.listing__created_at__extract_month - , subq_22.listing__created_at__extract_day - , subq_22.listing__created_at__extract_dow - , subq_22.listing__created_at__extract_doy - , subq_22.ds__day AS metric_time__day - , subq_22.ds__week AS metric_time__week - , subq_22.ds__month AS metric_time__month - , subq_22.ds__quarter AS metric_time__quarter - , subq_22.ds__year AS metric_time__year - , subq_22.ds__extract_year AS metric_time__extract_year - , subq_22.ds__extract_quarter AS metric_time__extract_quarter - , subq_22.ds__extract_month AS metric_time__extract_month - , subq_22.ds__extract_day AS metric_time__extract_day - , subq_22.ds__extract_dow AS metric_time__extract_dow - , subq_22.ds__extract_doy AS metric_time__extract_doy - , subq_22.listing - , subq_22.user - , subq_22.listing__user - , subq_22.country_latest - , subq_22.is_lux_latest - , subq_22.capacity_latest - , subq_22.listing__country_latest - , subq_22.listing__is_lux_latest - , subq_22.listing__capacity_latest - , subq_22.listings - , subq_22.largest_listing - , subq_22.smallest_listing + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.created_at__day + , subq_10.created_at__week + , subq_10.created_at__month + , subq_10.created_at__quarter + , subq_10.created_at__year + , subq_10.created_at__extract_year + , subq_10.created_at__extract_quarter + , subq_10.created_at__extract_month + , subq_10.created_at__extract_day + , subq_10.created_at__extract_dow + , subq_10.created_at__extract_doy + , subq_10.listing__ds__day + , subq_10.listing__ds__week + , subq_10.listing__ds__month + , subq_10.listing__ds__quarter + , subq_10.listing__ds__year + , subq_10.listing__ds__extract_year + , subq_10.listing__ds__extract_quarter + , subq_10.listing__ds__extract_month + , subq_10.listing__ds__extract_day + , subq_10.listing__ds__extract_dow + , subq_10.listing__ds__extract_doy + , subq_10.listing__created_at__day + , subq_10.listing__created_at__week + , subq_10.listing__created_at__month + , subq_10.listing__created_at__quarter + , subq_10.listing__created_at__year + , subq_10.listing__created_at__extract_year + , subq_10.listing__created_at__extract_quarter + , subq_10.listing__created_at__extract_month + , subq_10.listing__created_at__extract_day + , subq_10.listing__created_at__extract_dow + , subq_10.listing__created_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.user + , subq_10.listing__user + , subq_10.country_latest + , subq_10.is_lux_latest + , subq_10.capacity_latest + , subq_10.listing__country_latest + , subq_10.listing__is_lux_latest + , subq_10.listing__capacity_latest + , subq_10.listings + , subq_10.largest_listing + , subq_10.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -482,257 +482,257 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 - ) subq_23 - ) subq_24 + ) subq_10 + ) subq_11 + ) subq_12 ON - subq_21.listing = subq_24.listing - ) subq_25 - ) subq_26 + subq_9.listing = subq_12.listing + ) subq_13 + ) subq_14 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 + ) subq_15 + ) subq_16 + ) subq_17 + ) subq_18 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_42.bookings + subq_30.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_41.bookings) AS bookings + SUM(subq_29.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_40.bookings + subq_28.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_39.booking__is_instant - , subq_39.listing__is_lux_latest - , subq_39.bookings + subq_27.booking__is_instant + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_38.booking__is_instant - , subq_38.listing__is_lux_latest - , subq_38.bookings + subq_26.booking__is_instant + , subq_26.listing__is_lux_latest + , subq_26.bookings FROM ( -- Join Standard Outputs SELECT - subq_34.listing AS listing - , subq_34.booking__is_instant AS booking__is_instant - , subq_37.is_lux_latest AS listing__is_lux_latest - , subq_34.bookings AS bookings + subq_22.listing AS listing + , subq_22.booking__is_instant AS booking__is_instant + , subq_25.is_lux_latest AS listing__is_lux_latest + , subq_22.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_33.listing - , subq_33.booking__is_instant - , subq_33.bookings + subq_21.listing + , subq_21.booking__is_instant + , subq_21.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_32.ds__day - , subq_32.ds__week - , subq_32.ds__month - , subq_32.ds__quarter - , subq_32.ds__year - , subq_32.ds__extract_year - , subq_32.ds__extract_quarter - , subq_32.ds__extract_month - , subq_32.ds__extract_day - , subq_32.ds__extract_dow - , subq_32.ds__extract_doy - , subq_32.ds_partitioned__day - , subq_32.ds_partitioned__week - , subq_32.ds_partitioned__month - , subq_32.ds_partitioned__quarter - , subq_32.ds_partitioned__year - , subq_32.ds_partitioned__extract_year - , subq_32.ds_partitioned__extract_quarter - , subq_32.ds_partitioned__extract_month - , subq_32.ds_partitioned__extract_day - , subq_32.ds_partitioned__extract_dow - , subq_32.ds_partitioned__extract_doy - , subq_32.paid_at__day - , subq_32.paid_at__week - , subq_32.paid_at__month - , subq_32.paid_at__quarter - , subq_32.paid_at__year - , subq_32.paid_at__extract_year - , subq_32.paid_at__extract_quarter - , subq_32.paid_at__extract_month - , subq_32.paid_at__extract_day - , subq_32.paid_at__extract_dow - , subq_32.paid_at__extract_doy - , subq_32.booking__ds__day - , subq_32.booking__ds__week - , subq_32.booking__ds__month - , subq_32.booking__ds__quarter - , subq_32.booking__ds__year - , subq_32.booking__ds__extract_year - , subq_32.booking__ds__extract_quarter - , subq_32.booking__ds__extract_month - , subq_32.booking__ds__extract_day - , subq_32.booking__ds__extract_dow - , subq_32.booking__ds__extract_doy - , subq_32.booking__ds_partitioned__day - , subq_32.booking__ds_partitioned__week - , subq_32.booking__ds_partitioned__month - , subq_32.booking__ds_partitioned__quarter - , subq_32.booking__ds_partitioned__year - , subq_32.booking__ds_partitioned__extract_year - , subq_32.booking__ds_partitioned__extract_quarter - , subq_32.booking__ds_partitioned__extract_month - , subq_32.booking__ds_partitioned__extract_day - , subq_32.booking__ds_partitioned__extract_dow - , subq_32.booking__ds_partitioned__extract_doy - , subq_32.booking__paid_at__day - , subq_32.booking__paid_at__week - , subq_32.booking__paid_at__month - , subq_32.booking__paid_at__quarter - , subq_32.booking__paid_at__year - , subq_32.booking__paid_at__extract_year - , subq_32.booking__paid_at__extract_quarter - , subq_32.booking__paid_at__extract_month - , subq_32.booking__paid_at__extract_day - , subq_32.booking__paid_at__extract_dow - , subq_32.booking__paid_at__extract_doy - , subq_32.metric_time__day - , subq_32.metric_time__week - , subq_32.metric_time__month - , subq_32.metric_time__quarter - , subq_32.metric_time__year - , subq_32.metric_time__extract_year - , subq_32.metric_time__extract_quarter - , subq_32.metric_time__extract_month - , subq_32.metric_time__extract_day - , subq_32.metric_time__extract_dow - , subq_32.metric_time__extract_doy - , subq_32.listing - , subq_32.guest - , subq_32.host - , subq_32.booking__listing - , subq_32.booking__guest - , subq_32.booking__host - , subq_32.is_instant - , subq_32.booking__is_instant - , subq_32.bookings - , subq_32.instant_bookings - , subq_32.booking_value - , subq_32.max_booking_value - , subq_32.min_booking_value - , subq_32.bookers - , subq_32.average_booking_value - , subq_32.referred_bookings - , subq_32.median_booking_value - , subq_32.booking_value_p99 - , subq_32.discrete_booking_value_p99 - , subq_32.approximate_continuous_booking_value_p99 - , subq_32.approximate_discrete_booking_value_p99 + subq_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.metric_time__day + , subq_20.metric_time__week + , subq_20.metric_time__month + , subq_20.metric_time__quarter + , subq_20.metric_time__year + , subq_20.metric_time__extract_year + , subq_20.metric_time__extract_quarter + , subq_20.metric_time__extract_month + , subq_20.metric_time__extract_day + , subq_20.metric_time__extract_dow + , subq_20.metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_31.ds__day - , subq_31.ds__week - , subq_31.ds__month - , subq_31.ds__quarter - , subq_31.ds__year - , subq_31.ds__extract_year - , subq_31.ds__extract_quarter - , subq_31.ds__extract_month - , subq_31.ds__extract_day - , subq_31.ds__extract_dow - , subq_31.ds__extract_doy - , subq_31.ds_partitioned__day - , subq_31.ds_partitioned__week - , subq_31.ds_partitioned__month - , subq_31.ds_partitioned__quarter - , subq_31.ds_partitioned__year - , subq_31.ds_partitioned__extract_year - , subq_31.ds_partitioned__extract_quarter - , subq_31.ds_partitioned__extract_month - , subq_31.ds_partitioned__extract_day - , subq_31.ds_partitioned__extract_dow - , subq_31.ds_partitioned__extract_doy - , subq_31.paid_at__day - , subq_31.paid_at__week - , subq_31.paid_at__month - , subq_31.paid_at__quarter - , subq_31.paid_at__year - , subq_31.paid_at__extract_year - , subq_31.paid_at__extract_quarter - , subq_31.paid_at__extract_month - , subq_31.paid_at__extract_day - , subq_31.paid_at__extract_dow - , subq_31.paid_at__extract_doy - , subq_31.booking__ds__day - , subq_31.booking__ds__week - , subq_31.booking__ds__month - , subq_31.booking__ds__quarter - , subq_31.booking__ds__year - , subq_31.booking__ds__extract_year - , subq_31.booking__ds__extract_quarter - , subq_31.booking__ds__extract_month - , subq_31.booking__ds__extract_day - , subq_31.booking__ds__extract_dow - , subq_31.booking__ds__extract_doy - , subq_31.booking__ds_partitioned__day - , subq_31.booking__ds_partitioned__week - , subq_31.booking__ds_partitioned__month - , subq_31.booking__ds_partitioned__quarter - , subq_31.booking__ds_partitioned__year - , subq_31.booking__ds_partitioned__extract_year - , subq_31.booking__ds_partitioned__extract_quarter - , subq_31.booking__ds_partitioned__extract_month - , subq_31.booking__ds_partitioned__extract_day - , subq_31.booking__ds_partitioned__extract_dow - , subq_31.booking__ds_partitioned__extract_doy - , subq_31.booking__paid_at__day - , subq_31.booking__paid_at__week - , subq_31.booking__paid_at__month - , subq_31.booking__paid_at__quarter - , subq_31.booking__paid_at__year - , subq_31.booking__paid_at__extract_year - , subq_31.booking__paid_at__extract_quarter - , subq_31.booking__paid_at__extract_month - , subq_31.booking__paid_at__extract_day - , subq_31.booking__paid_at__extract_dow - , subq_31.booking__paid_at__extract_doy - , subq_31.ds__day AS metric_time__day - , subq_31.ds__week AS metric_time__week - , subq_31.ds__month AS metric_time__month - , subq_31.ds__quarter AS metric_time__quarter - , subq_31.ds__year AS metric_time__year - , subq_31.ds__extract_year AS metric_time__extract_year - , subq_31.ds__extract_quarter AS metric_time__extract_quarter - , subq_31.ds__extract_month AS metric_time__extract_month - , subq_31.ds__extract_day AS metric_time__extract_day - , subq_31.ds__extract_dow AS metric_time__extract_dow - , subq_31.ds__extract_doy AS metric_time__extract_doy - , subq_31.listing - , subq_31.guest - , subq_31.host - , subq_31.booking__listing - , subq_31.booking__guest - , subq_31.booking__host - , subq_31.is_instant - , subq_31.booking__is_instant - , subq_31.bookings - , subq_31.instant_bookings - , subq_31.booking_value - , subq_31.max_booking_value - , subq_31.min_booking_value - , subq_31.bookers - , subq_31.average_booking_value - , subq_31.referred_bookings - , subq_31.median_booking_value - , subq_31.booking_value_p99 - , subq_31.discrete_booking_value_p99 - , subq_31.approximate_continuous_booking_value_p99 - , subq_31.approximate_discrete_booking_value_p99 + subq_19.ds__day + , subq_19.ds__week + , subq_19.ds__month + , subq_19.ds__quarter + , subq_19.ds__year + , subq_19.ds__extract_year + , subq_19.ds__extract_quarter + , subq_19.ds__extract_month + , subq_19.ds__extract_day + , subq_19.ds__extract_dow + , subq_19.ds__extract_doy + , subq_19.ds_partitioned__day + , subq_19.ds_partitioned__week + , subq_19.ds_partitioned__month + , subq_19.ds_partitioned__quarter + , subq_19.ds_partitioned__year + , subq_19.ds_partitioned__extract_year + , subq_19.ds_partitioned__extract_quarter + , subq_19.ds_partitioned__extract_month + , subq_19.ds_partitioned__extract_day + , subq_19.ds_partitioned__extract_dow + , subq_19.ds_partitioned__extract_doy + , subq_19.paid_at__day + , subq_19.paid_at__week + , subq_19.paid_at__month + , subq_19.paid_at__quarter + , subq_19.paid_at__year + , subq_19.paid_at__extract_year + , subq_19.paid_at__extract_quarter + , subq_19.paid_at__extract_month + , subq_19.paid_at__extract_day + , subq_19.paid_at__extract_dow + , subq_19.paid_at__extract_doy + , subq_19.booking__ds__day + , subq_19.booking__ds__week + , subq_19.booking__ds__month + , subq_19.booking__ds__quarter + , subq_19.booking__ds__year + , subq_19.booking__ds__extract_year + , subq_19.booking__ds__extract_quarter + , subq_19.booking__ds__extract_month + , subq_19.booking__ds__extract_day + , subq_19.booking__ds__extract_dow + , subq_19.booking__ds__extract_doy + , subq_19.booking__ds_partitioned__day + , subq_19.booking__ds_partitioned__week + , subq_19.booking__ds_partitioned__month + , subq_19.booking__ds_partitioned__quarter + , subq_19.booking__ds_partitioned__year + , subq_19.booking__ds_partitioned__extract_year + , subq_19.booking__ds_partitioned__extract_quarter + , subq_19.booking__ds_partitioned__extract_month + , subq_19.booking__ds_partitioned__extract_day + , subq_19.booking__ds_partitioned__extract_dow + , subq_19.booking__ds_partitioned__extract_doy + , subq_19.booking__paid_at__day + , subq_19.booking__paid_at__week + , subq_19.booking__paid_at__month + , subq_19.booking__paid_at__quarter + , subq_19.booking__paid_at__year + , subq_19.booking__paid_at__extract_year + , subq_19.booking__paid_at__extract_quarter + , subq_19.booking__paid_at__extract_month + , subq_19.booking__paid_at__extract_day + , subq_19.booking__paid_at__extract_dow + , subq_19.booking__paid_at__extract_doy + , subq_19.ds__day AS metric_time__day + , subq_19.ds__week AS metric_time__week + , subq_19.ds__month AS metric_time__month + , subq_19.ds__quarter AS metric_time__quarter + , subq_19.ds__year AS metric_time__year + , subq_19.ds__extract_year AS metric_time__extract_year + , subq_19.ds__extract_quarter AS metric_time__extract_quarter + , subq_19.ds__extract_month AS metric_time__extract_month + , subq_19.ds__extract_day AS metric_time__extract_day + , subq_19.ds__extract_dow AS metric_time__extract_dow + , subq_19.ds__extract_doy AS metric_time__extract_doy + , subq_19.listing + , subq_19.guest + , subq_19.host + , subq_19.booking__listing + , subq_19.booking__guest + , subq_19.booking__host + , subq_19.is_instant + , subq_19.booking__is_instant + , subq_19.bookings + , subq_19.instant_bookings + , subq_19.booking_value + , subq_19.max_booking_value + , subq_19.min_booking_value + , subq_19.bookers + , subq_19.average_booking_value + , subq_19.referred_bookings + , subq_19.median_booking_value + , subq_19.booking_value_p99 + , subq_19.discrete_booking_value_p99 + , subq_19.approximate_continuous_booking_value_p99 + , subq_19.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -825,86 +825,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_31 - ) subq_32 + ) subq_19 + ) subq_20 WHERE booking__is_instant - ) subq_33 - ) subq_34 + ) subq_21 + ) subq_22 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_36.listing - , subq_36.is_lux_latest + subq_24.listing + , subq_24.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_35.ds__day - , subq_35.ds__week - , subq_35.ds__month - , subq_35.ds__quarter - , subq_35.ds__year - , subq_35.ds__extract_year - , subq_35.ds__extract_quarter - , subq_35.ds__extract_month - , subq_35.ds__extract_day - , subq_35.ds__extract_dow - , subq_35.ds__extract_doy - , subq_35.created_at__day - , subq_35.created_at__week - , subq_35.created_at__month - , subq_35.created_at__quarter - , subq_35.created_at__year - , subq_35.created_at__extract_year - , subq_35.created_at__extract_quarter - , subq_35.created_at__extract_month - , subq_35.created_at__extract_day - , subq_35.created_at__extract_dow - , subq_35.created_at__extract_doy - , subq_35.listing__ds__day - , subq_35.listing__ds__week - , subq_35.listing__ds__month - , subq_35.listing__ds__quarter - , subq_35.listing__ds__year - , subq_35.listing__ds__extract_year - , subq_35.listing__ds__extract_quarter - , subq_35.listing__ds__extract_month - , subq_35.listing__ds__extract_day - , subq_35.listing__ds__extract_dow - , subq_35.listing__ds__extract_doy - , subq_35.listing__created_at__day - , subq_35.listing__created_at__week - , subq_35.listing__created_at__month - , subq_35.listing__created_at__quarter - , subq_35.listing__created_at__year - , subq_35.listing__created_at__extract_year - , subq_35.listing__created_at__extract_quarter - , subq_35.listing__created_at__extract_month - , subq_35.listing__created_at__extract_day - , subq_35.listing__created_at__extract_dow - , subq_35.listing__created_at__extract_doy - , subq_35.ds__day AS metric_time__day - , subq_35.ds__week AS metric_time__week - , subq_35.ds__month AS metric_time__month - , subq_35.ds__quarter AS metric_time__quarter - , subq_35.ds__year AS metric_time__year - , subq_35.ds__extract_year AS metric_time__extract_year - , subq_35.ds__extract_quarter AS metric_time__extract_quarter - , subq_35.ds__extract_month AS metric_time__extract_month - , subq_35.ds__extract_day AS metric_time__extract_day - , subq_35.ds__extract_dow AS metric_time__extract_dow - , subq_35.ds__extract_doy AS metric_time__extract_doy - , subq_35.listing - , subq_35.user - , subq_35.listing__user - , subq_35.country_latest - , subq_35.is_lux_latest - , subq_35.capacity_latest - , subq_35.listing__country_latest - , subq_35.listing__is_lux_latest - , subq_35.listing__capacity_latest - , subq_35.listings - , subq_35.largest_listing - , subq_35.smallest_listing + subq_23.ds__day + , subq_23.ds__week + , subq_23.ds__month + , subq_23.ds__quarter + , subq_23.ds__year + , subq_23.ds__extract_year + , subq_23.ds__extract_quarter + , subq_23.ds__extract_month + , subq_23.ds__extract_day + , subq_23.ds__extract_dow + , subq_23.ds__extract_doy + , subq_23.created_at__day + , subq_23.created_at__week + , subq_23.created_at__month + , subq_23.created_at__quarter + , subq_23.created_at__year + , subq_23.created_at__extract_year + , subq_23.created_at__extract_quarter + , subq_23.created_at__extract_month + , subq_23.created_at__extract_day + , subq_23.created_at__extract_dow + , subq_23.created_at__extract_doy + , subq_23.listing__ds__day + , subq_23.listing__ds__week + , subq_23.listing__ds__month + , subq_23.listing__ds__quarter + , subq_23.listing__ds__year + , subq_23.listing__ds__extract_year + , subq_23.listing__ds__extract_quarter + , subq_23.listing__ds__extract_month + , subq_23.listing__ds__extract_day + , subq_23.listing__ds__extract_dow + , subq_23.listing__ds__extract_doy + , subq_23.listing__created_at__day + , subq_23.listing__created_at__week + , subq_23.listing__created_at__month + , subq_23.listing__created_at__quarter + , subq_23.listing__created_at__year + , subq_23.listing__created_at__extract_year + , subq_23.listing__created_at__extract_quarter + , subq_23.listing__created_at__extract_month + , subq_23.listing__created_at__extract_day + , subq_23.listing__created_at__extract_dow + , subq_23.listing__created_at__extract_doy + , subq_23.ds__day AS metric_time__day + , subq_23.ds__week AS metric_time__week + , subq_23.ds__month AS metric_time__month + , subq_23.ds__quarter AS metric_time__quarter + , subq_23.ds__year AS metric_time__year + , subq_23.ds__extract_year AS metric_time__extract_year + , subq_23.ds__extract_quarter AS metric_time__extract_quarter + , subq_23.ds__extract_month AS metric_time__extract_month + , subq_23.ds__extract_day AS metric_time__extract_day + , subq_23.ds__extract_dow AS metric_time__extract_dow + , subq_23.ds__extract_doy AS metric_time__extract_doy + , subq_23.listing + , subq_23.user + , subq_23.listing__user + , subq_23.country_latest + , subq_23.is_lux_latest + , subq_23.capacity_latest + , subq_23.listing__country_latest + , subq_23.listing__is_lux_latest + , subq_23.listing__capacity_latest + , subq_23.listings + , subq_23.largest_listing + , subq_23.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -965,242 +965,242 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_35 - ) subq_36 - ) subq_37 + ) subq_23 + ) subq_24 + ) subq_25 ON - subq_34.listing = subq_37.listing - ) subq_38 - ) subq_39 + subq_22.listing = subq_25.listing + ) subq_26 + ) subq_27 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_40 - ) subq_41 - ) subq_42 - ) subq_43 + ) subq_28 + ) subq_29 + ) subq_30 + ) subq_31 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_50.booking_value + subq_38.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_49.booking_value) AS booking_value + SUM(subq_37.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_48.booking_value + subq_36.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_47.booking__is_instant - , subq_47.booking_value + subq_35.booking__is_instant + , subq_35.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_46.booking__is_instant - , subq_46.booking_value + subq_34.booking__is_instant + , subq_34.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_45.ds__day - , subq_45.ds__week - , subq_45.ds__month - , subq_45.ds__quarter - , subq_45.ds__year - , subq_45.ds__extract_year - , subq_45.ds__extract_quarter - , subq_45.ds__extract_month - , subq_45.ds__extract_day - , subq_45.ds__extract_dow - , subq_45.ds__extract_doy - , subq_45.ds_partitioned__day - , subq_45.ds_partitioned__week - , subq_45.ds_partitioned__month - , subq_45.ds_partitioned__quarter - , subq_45.ds_partitioned__year - , subq_45.ds_partitioned__extract_year - , subq_45.ds_partitioned__extract_quarter - , subq_45.ds_partitioned__extract_month - , subq_45.ds_partitioned__extract_day - , subq_45.ds_partitioned__extract_dow - , subq_45.ds_partitioned__extract_doy - , subq_45.paid_at__day - , subq_45.paid_at__week - , subq_45.paid_at__month - , subq_45.paid_at__quarter - , subq_45.paid_at__year - , subq_45.paid_at__extract_year - , subq_45.paid_at__extract_quarter - , subq_45.paid_at__extract_month - , subq_45.paid_at__extract_day - , subq_45.paid_at__extract_dow - , subq_45.paid_at__extract_doy - , subq_45.booking__ds__day - , subq_45.booking__ds__week - , subq_45.booking__ds__month - , subq_45.booking__ds__quarter - , subq_45.booking__ds__year - , subq_45.booking__ds__extract_year - , subq_45.booking__ds__extract_quarter - , subq_45.booking__ds__extract_month - , subq_45.booking__ds__extract_day - , subq_45.booking__ds__extract_dow - , subq_45.booking__ds__extract_doy - , subq_45.booking__ds_partitioned__day - , subq_45.booking__ds_partitioned__week - , subq_45.booking__ds_partitioned__month - , subq_45.booking__ds_partitioned__quarter - , subq_45.booking__ds_partitioned__year - , subq_45.booking__ds_partitioned__extract_year - , subq_45.booking__ds_partitioned__extract_quarter - , subq_45.booking__ds_partitioned__extract_month - , subq_45.booking__ds_partitioned__extract_day - , subq_45.booking__ds_partitioned__extract_dow - , subq_45.booking__ds_partitioned__extract_doy - , subq_45.booking__paid_at__day - , subq_45.booking__paid_at__week - , subq_45.booking__paid_at__month - , subq_45.booking__paid_at__quarter - , subq_45.booking__paid_at__year - , subq_45.booking__paid_at__extract_year - , subq_45.booking__paid_at__extract_quarter - , subq_45.booking__paid_at__extract_month - , subq_45.booking__paid_at__extract_day - , subq_45.booking__paid_at__extract_dow - , subq_45.booking__paid_at__extract_doy - , subq_45.metric_time__day - , subq_45.metric_time__week - , subq_45.metric_time__month - , subq_45.metric_time__quarter - , subq_45.metric_time__year - , subq_45.metric_time__extract_year - , subq_45.metric_time__extract_quarter - , subq_45.metric_time__extract_month - , subq_45.metric_time__extract_day - , subq_45.metric_time__extract_dow - , subq_45.metric_time__extract_doy - , subq_45.listing - , subq_45.guest - , subq_45.host - , subq_45.booking__listing - , subq_45.booking__guest - , subq_45.booking__host - , subq_45.is_instant - , subq_45.booking__is_instant - , subq_45.bookings - , subq_45.instant_bookings - , subq_45.booking_value - , subq_45.max_booking_value - , subq_45.min_booking_value - , subq_45.bookers - , subq_45.average_booking_value - , subq_45.referred_bookings - , subq_45.median_booking_value - , subq_45.booking_value_p99 - , subq_45.discrete_booking_value_p99 - , subq_45.approximate_continuous_booking_value_p99 - , subq_45.approximate_discrete_booking_value_p99 + subq_33.ds__day + , subq_33.ds__week + , subq_33.ds__month + , subq_33.ds__quarter + , subq_33.ds__year + , subq_33.ds__extract_year + , subq_33.ds__extract_quarter + , subq_33.ds__extract_month + , subq_33.ds__extract_day + , subq_33.ds__extract_dow + , subq_33.ds__extract_doy + , subq_33.ds_partitioned__day + , subq_33.ds_partitioned__week + , subq_33.ds_partitioned__month + , subq_33.ds_partitioned__quarter + , subq_33.ds_partitioned__year + , subq_33.ds_partitioned__extract_year + , subq_33.ds_partitioned__extract_quarter + , subq_33.ds_partitioned__extract_month + , subq_33.ds_partitioned__extract_day + , subq_33.ds_partitioned__extract_dow + , subq_33.ds_partitioned__extract_doy + , subq_33.paid_at__day + , subq_33.paid_at__week + , subq_33.paid_at__month + , subq_33.paid_at__quarter + , subq_33.paid_at__year + , subq_33.paid_at__extract_year + , subq_33.paid_at__extract_quarter + , subq_33.paid_at__extract_month + , subq_33.paid_at__extract_day + , subq_33.paid_at__extract_dow + , subq_33.paid_at__extract_doy + , subq_33.booking__ds__day + , subq_33.booking__ds__week + , subq_33.booking__ds__month + , subq_33.booking__ds__quarter + , subq_33.booking__ds__year + , subq_33.booking__ds__extract_year + , subq_33.booking__ds__extract_quarter + , subq_33.booking__ds__extract_month + , subq_33.booking__ds__extract_day + , subq_33.booking__ds__extract_dow + , subq_33.booking__ds__extract_doy + , subq_33.booking__ds_partitioned__day + , subq_33.booking__ds_partitioned__week + , subq_33.booking__ds_partitioned__month + , subq_33.booking__ds_partitioned__quarter + , subq_33.booking__ds_partitioned__year + , subq_33.booking__ds_partitioned__extract_year + , subq_33.booking__ds_partitioned__extract_quarter + , subq_33.booking__ds_partitioned__extract_month + , subq_33.booking__ds_partitioned__extract_day + , subq_33.booking__ds_partitioned__extract_dow + , subq_33.booking__ds_partitioned__extract_doy + , subq_33.booking__paid_at__day + , subq_33.booking__paid_at__week + , subq_33.booking__paid_at__month + , subq_33.booking__paid_at__quarter + , subq_33.booking__paid_at__year + , subq_33.booking__paid_at__extract_year + , subq_33.booking__paid_at__extract_quarter + , subq_33.booking__paid_at__extract_month + , subq_33.booking__paid_at__extract_day + , subq_33.booking__paid_at__extract_dow + , subq_33.booking__paid_at__extract_doy + , subq_33.metric_time__day + , subq_33.metric_time__week + , subq_33.metric_time__month + , subq_33.metric_time__quarter + , subq_33.metric_time__year + , subq_33.metric_time__extract_year + , subq_33.metric_time__extract_quarter + , subq_33.metric_time__extract_month + , subq_33.metric_time__extract_day + , subq_33.metric_time__extract_dow + , subq_33.metric_time__extract_doy + , subq_33.listing + , subq_33.guest + , subq_33.host + , subq_33.booking__listing + , subq_33.booking__guest + , subq_33.booking__host + , subq_33.is_instant + , subq_33.booking__is_instant + , subq_33.bookings + , subq_33.instant_bookings + , subq_33.booking_value + , subq_33.max_booking_value + , subq_33.min_booking_value + , subq_33.bookers + , subq_33.average_booking_value + , subq_33.referred_bookings + , subq_33.median_booking_value + , subq_33.booking_value_p99 + , subq_33.discrete_booking_value_p99 + , subq_33.approximate_continuous_booking_value_p99 + , subq_33.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_44.ds__day - , subq_44.ds__week - , subq_44.ds__month - , subq_44.ds__quarter - , subq_44.ds__year - , subq_44.ds__extract_year - , subq_44.ds__extract_quarter - , subq_44.ds__extract_month - , subq_44.ds__extract_day - , subq_44.ds__extract_dow - , subq_44.ds__extract_doy - , subq_44.ds_partitioned__day - , subq_44.ds_partitioned__week - , subq_44.ds_partitioned__month - , subq_44.ds_partitioned__quarter - , subq_44.ds_partitioned__year - , subq_44.ds_partitioned__extract_year - , subq_44.ds_partitioned__extract_quarter - , subq_44.ds_partitioned__extract_month - , subq_44.ds_partitioned__extract_day - , subq_44.ds_partitioned__extract_dow - , subq_44.ds_partitioned__extract_doy - , subq_44.paid_at__day - , subq_44.paid_at__week - , subq_44.paid_at__month - , subq_44.paid_at__quarter - , subq_44.paid_at__year - , subq_44.paid_at__extract_year - , subq_44.paid_at__extract_quarter - , subq_44.paid_at__extract_month - , subq_44.paid_at__extract_day - , subq_44.paid_at__extract_dow - , subq_44.paid_at__extract_doy - , subq_44.booking__ds__day - , subq_44.booking__ds__week - , subq_44.booking__ds__month - , subq_44.booking__ds__quarter - , subq_44.booking__ds__year - , subq_44.booking__ds__extract_year - , subq_44.booking__ds__extract_quarter - , subq_44.booking__ds__extract_month - , subq_44.booking__ds__extract_day - , subq_44.booking__ds__extract_dow - , subq_44.booking__ds__extract_doy - , subq_44.booking__ds_partitioned__day - , subq_44.booking__ds_partitioned__week - , subq_44.booking__ds_partitioned__month - , subq_44.booking__ds_partitioned__quarter - , subq_44.booking__ds_partitioned__year - , subq_44.booking__ds_partitioned__extract_year - , subq_44.booking__ds_partitioned__extract_quarter - , subq_44.booking__ds_partitioned__extract_month - , subq_44.booking__ds_partitioned__extract_day - , subq_44.booking__ds_partitioned__extract_dow - , subq_44.booking__ds_partitioned__extract_doy - , subq_44.booking__paid_at__day - , subq_44.booking__paid_at__week - , subq_44.booking__paid_at__month - , subq_44.booking__paid_at__quarter - , subq_44.booking__paid_at__year - , subq_44.booking__paid_at__extract_year - , subq_44.booking__paid_at__extract_quarter - , subq_44.booking__paid_at__extract_month - , subq_44.booking__paid_at__extract_day - , subq_44.booking__paid_at__extract_dow - , subq_44.booking__paid_at__extract_doy - , subq_44.ds__day AS metric_time__day - , subq_44.ds__week AS metric_time__week - , subq_44.ds__month AS metric_time__month - , subq_44.ds__quarter AS metric_time__quarter - , subq_44.ds__year AS metric_time__year - , subq_44.ds__extract_year AS metric_time__extract_year - , subq_44.ds__extract_quarter AS metric_time__extract_quarter - , subq_44.ds__extract_month AS metric_time__extract_month - , subq_44.ds__extract_day AS metric_time__extract_day - , subq_44.ds__extract_dow AS metric_time__extract_dow - , subq_44.ds__extract_doy AS metric_time__extract_doy - , subq_44.listing - , subq_44.guest - , subq_44.host - , subq_44.booking__listing - , subq_44.booking__guest - , subq_44.booking__host - , subq_44.is_instant - , subq_44.booking__is_instant - , subq_44.bookings - , subq_44.instant_bookings - , subq_44.booking_value - , subq_44.max_booking_value - , subq_44.min_booking_value - , subq_44.bookers - , subq_44.average_booking_value - , subq_44.referred_bookings - , subq_44.median_booking_value - , subq_44.booking_value_p99 - , subq_44.discrete_booking_value_p99 - , subq_44.approximate_continuous_booking_value_p99 - , subq_44.approximate_discrete_booking_value_p99 + subq_32.ds__day + , subq_32.ds__week + , subq_32.ds__month + , subq_32.ds__quarter + , subq_32.ds__year + , subq_32.ds__extract_year + , subq_32.ds__extract_quarter + , subq_32.ds__extract_month + , subq_32.ds__extract_day + , subq_32.ds__extract_dow + , subq_32.ds__extract_doy + , subq_32.ds_partitioned__day + , subq_32.ds_partitioned__week + , subq_32.ds_partitioned__month + , subq_32.ds_partitioned__quarter + , subq_32.ds_partitioned__year + , subq_32.ds_partitioned__extract_year + , subq_32.ds_partitioned__extract_quarter + , subq_32.ds_partitioned__extract_month + , subq_32.ds_partitioned__extract_day + , subq_32.ds_partitioned__extract_dow + , subq_32.ds_partitioned__extract_doy + , subq_32.paid_at__day + , subq_32.paid_at__week + , subq_32.paid_at__month + , subq_32.paid_at__quarter + , subq_32.paid_at__year + , subq_32.paid_at__extract_year + , subq_32.paid_at__extract_quarter + , subq_32.paid_at__extract_month + , subq_32.paid_at__extract_day + , subq_32.paid_at__extract_dow + , subq_32.paid_at__extract_doy + , subq_32.booking__ds__day + , subq_32.booking__ds__week + , subq_32.booking__ds__month + , subq_32.booking__ds__quarter + , subq_32.booking__ds__year + , subq_32.booking__ds__extract_year + , subq_32.booking__ds__extract_quarter + , subq_32.booking__ds__extract_month + , subq_32.booking__ds__extract_day + , subq_32.booking__ds__extract_dow + , subq_32.booking__ds__extract_doy + , subq_32.booking__ds_partitioned__day + , subq_32.booking__ds_partitioned__week + , subq_32.booking__ds_partitioned__month + , subq_32.booking__ds_partitioned__quarter + , subq_32.booking__ds_partitioned__year + , subq_32.booking__ds_partitioned__extract_year + , subq_32.booking__ds_partitioned__extract_quarter + , subq_32.booking__ds_partitioned__extract_month + , subq_32.booking__ds_partitioned__extract_day + , subq_32.booking__ds_partitioned__extract_dow + , subq_32.booking__ds_partitioned__extract_doy + , subq_32.booking__paid_at__day + , subq_32.booking__paid_at__week + , subq_32.booking__paid_at__month + , subq_32.booking__paid_at__quarter + , subq_32.booking__paid_at__year + , subq_32.booking__paid_at__extract_year + , subq_32.booking__paid_at__extract_quarter + , subq_32.booking__paid_at__extract_month + , subq_32.booking__paid_at__extract_day + , subq_32.booking__paid_at__extract_dow + , subq_32.booking__paid_at__extract_doy + , subq_32.ds__day AS metric_time__day + , subq_32.ds__week AS metric_time__week + , subq_32.ds__month AS metric_time__month + , subq_32.ds__quarter AS metric_time__quarter + , subq_32.ds__year AS metric_time__year + , subq_32.ds__extract_year AS metric_time__extract_year + , subq_32.ds__extract_quarter AS metric_time__extract_quarter + , subq_32.ds__extract_month AS metric_time__extract_month + , subq_32.ds__extract_day AS metric_time__extract_day + , subq_32.ds__extract_dow AS metric_time__extract_dow + , subq_32.ds__extract_doy AS metric_time__extract_doy + , subq_32.listing + , subq_32.guest + , subq_32.host + , subq_32.booking__listing + , subq_32.booking__guest + , subq_32.booking__host + , subq_32.is_instant + , subq_32.booking__is_instant + , subq_32.bookings + , subq_32.instant_bookings + , subq_32.booking_value + , subq_32.max_booking_value + , subq_32.min_booking_value + , subq_32.bookers + , subq_32.average_booking_value + , subq_32.referred_bookings + , subq_32.median_booking_value + , subq_32.booking_value_p99 + , subq_32.discrete_booking_value_p99 + , subq_32.approximate_continuous_booking_value_p99 + , subq_32.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -1293,15 +1293,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_44 - ) subq_45 + ) subq_32 + ) subq_33 WHERE booking__is_instant - ) subq_46 - ) subq_47 + ) subq_34 + ) subq_35 WHERE booking__is_instant - ) subq_48 - ) subq_49 - ) subq_50 - ) subq_51 - ) subq_52 -) subq_53 + ) subq_36 + ) subq_37 + ) subq_38 + ) subq_39 + ) subq_40 +) subq_41 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/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 a0fdc735bd..60a09b752b 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_66.average_booking_value) AS average_booking_value - , MAX(subq_79.bookings) AS bookings - , MAX(subq_87.booking_value) AS booking_value + MAX(subq_54.average_booking_value) AS average_booking_value + , MAX(subq_67.bookings) AS bookings + , MAX(subq_75.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value',] @@ -22,9 +22,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_57.booking__is_instant AS booking__is_instant + subq_45.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_57.average_booking_value AS average_booking_value + , subq_45.average_booking_value AS average_booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] @@ -40,16 +40,16 @@ FROM ( , is_instant AS booking__is_instant , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_55 + ) subq_43 WHERE booking__is_instant - ) subq_57 + ) subq_45 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_57.listing = listings_latest_src_28000.listing_id - ) subq_62 + subq_45.listing = listings_latest_src_28000.listing_id + ) subq_50 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_66 + ) subq_54 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings',] @@ -61,9 +61,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_70.booking__is_instant AS booking__is_instant + subq_58.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_70.bookings AS bookings + , subq_58.bookings AS bookings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] @@ -79,16 +79,16 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_68 + ) subq_56 WHERE booking__is_instant - ) subq_70 + ) subq_58 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_70.listing = listings_latest_src_28000.listing_id - ) subq_75 + subq_58.listing = listings_latest_src_28000.listing_id + ) subq_63 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_79 + ) subq_67 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -109,10 +109,10 @@ FROM ( is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_81 + ) subq_69 WHERE booking__is_instant - ) subq_83 + ) subq_71 WHERE booking__is_instant - ) subq_87 - ) subq_88 -) subq_89 + ) subq_75 + ) subq_76 +) subq_77 diff --git a/tests_metricflow/snapshots/test_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 d6ea5d1211..6fea622708 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_30.average_booking_value) AS average_booking_value - , MAX(subq_43.bookings) AS bookings - , MAX(subq_51.booking_value) AS booking_value + MAX(subq_18.average_booking_value) AS average_booking_value + , MAX(subq_31.bookings) AS bookings + , MAX(subq_39.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_29.average_booking_value + subq_17.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_28.average_booking_value) AS average_booking_value + AVG(subq_16.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_27.average_booking_value + subq_15.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.listing__is_lux_latest - , subq_26.average_booking_value + subq_14.booking__is_instant + , subq_14.listing__is_lux_latest + , subq_14.average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_25.booking__is_instant - , subq_25.listing__is_lux_latest - , subq_25.average_booking_value + subq_13.booking__is_instant + , subq_13.listing__is_lux_latest + , subq_13.average_booking_value FROM ( -- Join Standard Outputs SELECT - subq_21.listing AS listing - , subq_21.booking__is_instant AS booking__is_instant - , subq_24.is_lux_latest AS listing__is_lux_latest - , subq_21.average_booking_value AS average_booking_value + subq_9.listing AS listing + , subq_9.booking__is_instant AS booking__is_instant + , subq_12.is_lux_latest AS listing__is_lux_latest + , subq_9.average_booking_value AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] SELECT - subq_20.listing - , subq_20.booking__is_instant - , subq_20.average_booking_value + subq_8.listing + , subq_8.booking__is_instant + , subq_8.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_19.ds__day - , subq_19.ds__week - , subq_19.ds__month - , subq_19.ds__quarter - , subq_19.ds__year - , subq_19.ds__extract_year - , subq_19.ds__extract_quarter - , subq_19.ds__extract_month - , subq_19.ds__extract_day - , subq_19.ds__extract_dow - , subq_19.ds__extract_doy - , subq_19.ds_partitioned__day - , subq_19.ds_partitioned__week - , subq_19.ds_partitioned__month - , subq_19.ds_partitioned__quarter - , subq_19.ds_partitioned__year - , subq_19.ds_partitioned__extract_year - , subq_19.ds_partitioned__extract_quarter - , subq_19.ds_partitioned__extract_month - , subq_19.ds_partitioned__extract_day - , subq_19.ds_partitioned__extract_dow - , subq_19.ds_partitioned__extract_doy - , subq_19.paid_at__day - , subq_19.paid_at__week - , subq_19.paid_at__month - , subq_19.paid_at__quarter - , subq_19.paid_at__year - , subq_19.paid_at__extract_year - , subq_19.paid_at__extract_quarter - , subq_19.paid_at__extract_month - , subq_19.paid_at__extract_day - , subq_19.paid_at__extract_dow - , subq_19.paid_at__extract_doy - , subq_19.booking__ds__day - , subq_19.booking__ds__week - , subq_19.booking__ds__month - , subq_19.booking__ds__quarter - , subq_19.booking__ds__year - , subq_19.booking__ds__extract_year - , subq_19.booking__ds__extract_quarter - , subq_19.booking__ds__extract_month - , subq_19.booking__ds__extract_day - , subq_19.booking__ds__extract_dow - , subq_19.booking__ds__extract_doy - , subq_19.booking__ds_partitioned__day - , subq_19.booking__ds_partitioned__week - , subq_19.booking__ds_partitioned__month - , subq_19.booking__ds_partitioned__quarter - , subq_19.booking__ds_partitioned__year - , subq_19.booking__ds_partitioned__extract_year - , subq_19.booking__ds_partitioned__extract_quarter - , subq_19.booking__ds_partitioned__extract_month - , subq_19.booking__ds_partitioned__extract_day - , subq_19.booking__ds_partitioned__extract_dow - , subq_19.booking__ds_partitioned__extract_doy - , subq_19.booking__paid_at__day - , subq_19.booking__paid_at__week - , subq_19.booking__paid_at__month - , subq_19.booking__paid_at__quarter - , subq_19.booking__paid_at__year - , subq_19.booking__paid_at__extract_year - , subq_19.booking__paid_at__extract_quarter - , subq_19.booking__paid_at__extract_month - , subq_19.booking__paid_at__extract_day - , subq_19.booking__paid_at__extract_dow - , subq_19.booking__paid_at__extract_doy - , subq_19.metric_time__day - , subq_19.metric_time__week - , subq_19.metric_time__month - , subq_19.metric_time__quarter - , subq_19.metric_time__year - , subq_19.metric_time__extract_year - , subq_19.metric_time__extract_quarter - , subq_19.metric_time__extract_month - , subq_19.metric_time__extract_day - , subq_19.metric_time__extract_dow - , subq_19.metric_time__extract_doy - , subq_19.listing - , subq_19.guest - , subq_19.host - , subq_19.booking__listing - , subq_19.booking__guest - , subq_19.booking__host - , subq_19.is_instant - , subq_19.booking__is_instant - , subq_19.bookings - , subq_19.instant_bookings - , subq_19.booking_value - , subq_19.max_booking_value - , subq_19.min_booking_value - , subq_19.bookers - , subq_19.average_booking_value - , subq_19.referred_bookings - , subq_19.median_booking_value - , subq_19.booking_value_p99 - , subq_19.discrete_booking_value_p99 - , subq_19.approximate_continuous_booking_value_p99 - , subq_19.approximate_discrete_booking_value_p99 + subq_7.ds__day + , subq_7.ds__week + , subq_7.ds__month + , subq_7.ds__quarter + , subq_7.ds__year + , subq_7.ds__extract_year + , subq_7.ds__extract_quarter + , subq_7.ds__extract_month + , subq_7.ds__extract_day + , subq_7.ds__extract_dow + , subq_7.ds__extract_doy + , subq_7.ds_partitioned__day + , subq_7.ds_partitioned__week + , subq_7.ds_partitioned__month + , subq_7.ds_partitioned__quarter + , subq_7.ds_partitioned__year + , subq_7.ds_partitioned__extract_year + , subq_7.ds_partitioned__extract_quarter + , subq_7.ds_partitioned__extract_month + , subq_7.ds_partitioned__extract_day + , subq_7.ds_partitioned__extract_dow + , subq_7.ds_partitioned__extract_doy + , subq_7.paid_at__day + , subq_7.paid_at__week + , subq_7.paid_at__month + , subq_7.paid_at__quarter + , subq_7.paid_at__year + , subq_7.paid_at__extract_year + , subq_7.paid_at__extract_quarter + , subq_7.paid_at__extract_month + , subq_7.paid_at__extract_day + , subq_7.paid_at__extract_dow + , subq_7.paid_at__extract_doy + , subq_7.booking__ds__day + , subq_7.booking__ds__week + , subq_7.booking__ds__month + , subq_7.booking__ds__quarter + , subq_7.booking__ds__year + , subq_7.booking__ds__extract_year + , subq_7.booking__ds__extract_quarter + , subq_7.booking__ds__extract_month + , subq_7.booking__ds__extract_day + , subq_7.booking__ds__extract_dow + , subq_7.booking__ds__extract_doy + , subq_7.booking__ds_partitioned__day + , subq_7.booking__ds_partitioned__week + , subq_7.booking__ds_partitioned__month + , subq_7.booking__ds_partitioned__quarter + , subq_7.booking__ds_partitioned__year + , subq_7.booking__ds_partitioned__extract_year + , subq_7.booking__ds_partitioned__extract_quarter + , subq_7.booking__ds_partitioned__extract_month + , subq_7.booking__ds_partitioned__extract_day + , subq_7.booking__ds_partitioned__extract_dow + , subq_7.booking__ds_partitioned__extract_doy + , subq_7.booking__paid_at__day + , subq_7.booking__paid_at__week + , subq_7.booking__paid_at__month + , subq_7.booking__paid_at__quarter + , subq_7.booking__paid_at__year + , subq_7.booking__paid_at__extract_year + , subq_7.booking__paid_at__extract_quarter + , subq_7.booking__paid_at__extract_month + , subq_7.booking__paid_at__extract_day + , subq_7.booking__paid_at__extract_dow + , subq_7.booking__paid_at__extract_doy + , subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.metric_time__month + , subq_7.metric_time__quarter + , subq_7.metric_time__year + , subq_7.metric_time__extract_year + , subq_7.metric_time__extract_quarter + , subq_7.metric_time__extract_month + , subq_7.metric_time__extract_day + , subq_7.metric_time__extract_dow + , subq_7.metric_time__extract_doy + , subq_7.listing + , subq_7.guest + , subq_7.host + , subq_7.booking__listing + , subq_7.booking__guest + , subq_7.booking__host + , subq_7.is_instant + , subq_7.booking__is_instant + , subq_7.bookings + , subq_7.instant_bookings + , subq_7.booking_value + , subq_7.max_booking_value + , subq_7.min_booking_value + , subq_7.bookers + , subq_7.average_booking_value + , subq_7.referred_bookings + , subq_7.median_booking_value + , subq_7.booking_value_p99 + , subq_7.discrete_booking_value_p99 + , subq_7.approximate_continuous_booking_value_p99 + , subq_7.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.ds_partitioned__day - , subq_18.ds_partitioned__week - , subq_18.ds_partitioned__month - , subq_18.ds_partitioned__quarter - , subq_18.ds_partitioned__year - , subq_18.ds_partitioned__extract_year - , subq_18.ds_partitioned__extract_quarter - , subq_18.ds_partitioned__extract_month - , subq_18.ds_partitioned__extract_day - , subq_18.ds_partitioned__extract_dow - , subq_18.ds_partitioned__extract_doy - , subq_18.paid_at__day - , subq_18.paid_at__week - , subq_18.paid_at__month - , subq_18.paid_at__quarter - , subq_18.paid_at__year - , subq_18.paid_at__extract_year - , subq_18.paid_at__extract_quarter - , subq_18.paid_at__extract_month - , subq_18.paid_at__extract_day - , subq_18.paid_at__extract_dow - , subq_18.paid_at__extract_doy - , subq_18.booking__ds__day - , subq_18.booking__ds__week - , subq_18.booking__ds__month - , subq_18.booking__ds__quarter - , subq_18.booking__ds__year - , subq_18.booking__ds__extract_year - , subq_18.booking__ds__extract_quarter - , subq_18.booking__ds__extract_month - , subq_18.booking__ds__extract_day - , subq_18.booking__ds__extract_dow - , subq_18.booking__ds__extract_doy - , subq_18.booking__ds_partitioned__day - , subq_18.booking__ds_partitioned__week - , subq_18.booking__ds_partitioned__month - , subq_18.booking__ds_partitioned__quarter - , subq_18.booking__ds_partitioned__year - , subq_18.booking__ds_partitioned__extract_year - , subq_18.booking__ds_partitioned__extract_quarter - , subq_18.booking__ds_partitioned__extract_month - , subq_18.booking__ds_partitioned__extract_day - , subq_18.booking__ds_partitioned__extract_dow - , subq_18.booking__ds_partitioned__extract_doy - , subq_18.booking__paid_at__day - , subq_18.booking__paid_at__week - , subq_18.booking__paid_at__month - , subq_18.booking__paid_at__quarter - , subq_18.booking__paid_at__year - , subq_18.booking__paid_at__extract_year - , subq_18.booking__paid_at__extract_quarter - , subq_18.booking__paid_at__extract_month - , subq_18.booking__paid_at__extract_day - , subq_18.booking__paid_at__extract_dow - , subq_18.booking__paid_at__extract_doy - , subq_18.ds__day AS metric_time__day - , subq_18.ds__week AS metric_time__week - , subq_18.ds__month AS metric_time__month - , subq_18.ds__quarter AS metric_time__quarter - , subq_18.ds__year AS metric_time__year - , subq_18.ds__extract_year AS metric_time__extract_year - , subq_18.ds__extract_quarter AS metric_time__extract_quarter - , subq_18.ds__extract_month AS metric_time__extract_month - , subq_18.ds__extract_day AS metric_time__extract_day - , subq_18.ds__extract_dow AS metric_time__extract_dow - , subq_18.ds__extract_doy AS metric_time__extract_doy - , subq_18.listing - , subq_18.guest - , subq_18.host - , subq_18.booking__listing - , subq_18.booking__guest - , subq_18.booking__host - , subq_18.is_instant - , subq_18.booking__is_instant - , subq_18.bookings - , subq_18.instant_bookings - , subq_18.booking_value - , subq_18.max_booking_value - , subq_18.min_booking_value - , subq_18.bookers - , subq_18.average_booking_value - , subq_18.referred_bookings - , subq_18.median_booking_value - , subq_18.booking_value_p99 - , subq_18.discrete_booking_value_p99 - , subq_18.approximate_continuous_booking_value_p99 - , subq_18.approximate_discrete_booking_value_p99 + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -342,86 +342,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_18 - ) subq_19 + ) subq_6 + ) subq_7 WHERE booking__is_instant - ) subq_20 - ) subq_21 + ) subq_8 + ) subq_9 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_23.listing - , subq_23.is_lux_latest + subq_11.listing + , subq_11.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_22.ds__day - , subq_22.ds__week - , subq_22.ds__month - , subq_22.ds__quarter - , subq_22.ds__year - , subq_22.ds__extract_year - , subq_22.ds__extract_quarter - , subq_22.ds__extract_month - , subq_22.ds__extract_day - , subq_22.ds__extract_dow - , subq_22.ds__extract_doy - , subq_22.created_at__day - , subq_22.created_at__week - , subq_22.created_at__month - , subq_22.created_at__quarter - , subq_22.created_at__year - , subq_22.created_at__extract_year - , subq_22.created_at__extract_quarter - , subq_22.created_at__extract_month - , subq_22.created_at__extract_day - , subq_22.created_at__extract_dow - , subq_22.created_at__extract_doy - , subq_22.listing__ds__day - , subq_22.listing__ds__week - , subq_22.listing__ds__month - , subq_22.listing__ds__quarter - , subq_22.listing__ds__year - , subq_22.listing__ds__extract_year - , subq_22.listing__ds__extract_quarter - , subq_22.listing__ds__extract_month - , subq_22.listing__ds__extract_day - , subq_22.listing__ds__extract_dow - , subq_22.listing__ds__extract_doy - , subq_22.listing__created_at__day - , subq_22.listing__created_at__week - , subq_22.listing__created_at__month - , subq_22.listing__created_at__quarter - , subq_22.listing__created_at__year - , subq_22.listing__created_at__extract_year - , subq_22.listing__created_at__extract_quarter - , subq_22.listing__created_at__extract_month - , subq_22.listing__created_at__extract_day - , subq_22.listing__created_at__extract_dow - , subq_22.listing__created_at__extract_doy - , subq_22.ds__day AS metric_time__day - , subq_22.ds__week AS metric_time__week - , subq_22.ds__month AS metric_time__month - , subq_22.ds__quarter AS metric_time__quarter - , subq_22.ds__year AS metric_time__year - , subq_22.ds__extract_year AS metric_time__extract_year - , subq_22.ds__extract_quarter AS metric_time__extract_quarter - , subq_22.ds__extract_month AS metric_time__extract_month - , subq_22.ds__extract_day AS metric_time__extract_day - , subq_22.ds__extract_dow AS metric_time__extract_dow - , subq_22.ds__extract_doy AS metric_time__extract_doy - , subq_22.listing - , subq_22.user - , subq_22.listing__user - , subq_22.country_latest - , subq_22.is_lux_latest - , subq_22.capacity_latest - , subq_22.listing__country_latest - , subq_22.listing__is_lux_latest - , subq_22.listing__capacity_latest - , subq_22.listings - , subq_22.largest_listing - , subq_22.smallest_listing + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.created_at__day + , subq_10.created_at__week + , subq_10.created_at__month + , subq_10.created_at__quarter + , subq_10.created_at__year + , subq_10.created_at__extract_year + , subq_10.created_at__extract_quarter + , subq_10.created_at__extract_month + , subq_10.created_at__extract_day + , subq_10.created_at__extract_dow + , subq_10.created_at__extract_doy + , subq_10.listing__ds__day + , subq_10.listing__ds__week + , subq_10.listing__ds__month + , subq_10.listing__ds__quarter + , subq_10.listing__ds__year + , subq_10.listing__ds__extract_year + , subq_10.listing__ds__extract_quarter + , subq_10.listing__ds__extract_month + , subq_10.listing__ds__extract_day + , subq_10.listing__ds__extract_dow + , subq_10.listing__ds__extract_doy + , subq_10.listing__created_at__day + , subq_10.listing__created_at__week + , subq_10.listing__created_at__month + , subq_10.listing__created_at__quarter + , subq_10.listing__created_at__year + , subq_10.listing__created_at__extract_year + , subq_10.listing__created_at__extract_quarter + , subq_10.listing__created_at__extract_month + , subq_10.listing__created_at__extract_day + , subq_10.listing__created_at__extract_dow + , subq_10.listing__created_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.user + , subq_10.listing__user + , subq_10.country_latest + , subq_10.is_lux_latest + , subq_10.capacity_latest + , subq_10.listing__country_latest + , subq_10.listing__is_lux_latest + , subq_10.listing__capacity_latest + , subq_10.listings + , subq_10.largest_listing + , subq_10.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -482,257 +482,257 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 - ) subq_23 - ) subq_24 + ) subq_10 + ) subq_11 + ) subq_12 ON - subq_21.listing = subq_24.listing - ) subq_25 - ) subq_26 + subq_9.listing = subq_12.listing + ) subq_13 + ) subq_14 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 + ) subq_15 + ) subq_16 + ) subq_17 + ) subq_18 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_42.bookings + subq_30.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_41.bookings) AS bookings + SUM(subq_29.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_40.bookings + subq_28.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_39.booking__is_instant - , subq_39.listing__is_lux_latest - , subq_39.bookings + subq_27.booking__is_instant + , subq_27.listing__is_lux_latest + , subq_27.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_38.booking__is_instant - , subq_38.listing__is_lux_latest - , subq_38.bookings + subq_26.booking__is_instant + , subq_26.listing__is_lux_latest + , subq_26.bookings FROM ( -- Join Standard Outputs SELECT - subq_34.listing AS listing - , subq_34.booking__is_instant AS booking__is_instant - , subq_37.is_lux_latest AS listing__is_lux_latest - , subq_34.bookings AS bookings + subq_22.listing AS listing + , subq_22.booking__is_instant AS booking__is_instant + , subq_25.is_lux_latest AS listing__is_lux_latest + , subq_22.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_33.listing - , subq_33.booking__is_instant - , subq_33.bookings + subq_21.listing + , subq_21.booking__is_instant + , subq_21.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_32.ds__day - , subq_32.ds__week - , subq_32.ds__month - , subq_32.ds__quarter - , subq_32.ds__year - , subq_32.ds__extract_year - , subq_32.ds__extract_quarter - , subq_32.ds__extract_month - , subq_32.ds__extract_day - , subq_32.ds__extract_dow - , subq_32.ds__extract_doy - , subq_32.ds_partitioned__day - , subq_32.ds_partitioned__week - , subq_32.ds_partitioned__month - , subq_32.ds_partitioned__quarter - , subq_32.ds_partitioned__year - , subq_32.ds_partitioned__extract_year - , subq_32.ds_partitioned__extract_quarter - , subq_32.ds_partitioned__extract_month - , subq_32.ds_partitioned__extract_day - , subq_32.ds_partitioned__extract_dow - , subq_32.ds_partitioned__extract_doy - , subq_32.paid_at__day - , subq_32.paid_at__week - , subq_32.paid_at__month - , subq_32.paid_at__quarter - , subq_32.paid_at__year - , subq_32.paid_at__extract_year - , subq_32.paid_at__extract_quarter - , subq_32.paid_at__extract_month - , subq_32.paid_at__extract_day - , subq_32.paid_at__extract_dow - , subq_32.paid_at__extract_doy - , subq_32.booking__ds__day - , subq_32.booking__ds__week - , subq_32.booking__ds__month - , subq_32.booking__ds__quarter - , subq_32.booking__ds__year - , subq_32.booking__ds__extract_year - , subq_32.booking__ds__extract_quarter - , subq_32.booking__ds__extract_month - , subq_32.booking__ds__extract_day - , subq_32.booking__ds__extract_dow - , subq_32.booking__ds__extract_doy - , subq_32.booking__ds_partitioned__day - , subq_32.booking__ds_partitioned__week - , subq_32.booking__ds_partitioned__month - , subq_32.booking__ds_partitioned__quarter - , subq_32.booking__ds_partitioned__year - , subq_32.booking__ds_partitioned__extract_year - , subq_32.booking__ds_partitioned__extract_quarter - , subq_32.booking__ds_partitioned__extract_month - , subq_32.booking__ds_partitioned__extract_day - , subq_32.booking__ds_partitioned__extract_dow - , subq_32.booking__ds_partitioned__extract_doy - , subq_32.booking__paid_at__day - , subq_32.booking__paid_at__week - , subq_32.booking__paid_at__month - , subq_32.booking__paid_at__quarter - , subq_32.booking__paid_at__year - , subq_32.booking__paid_at__extract_year - , subq_32.booking__paid_at__extract_quarter - , subq_32.booking__paid_at__extract_month - , subq_32.booking__paid_at__extract_day - , subq_32.booking__paid_at__extract_dow - , subq_32.booking__paid_at__extract_doy - , subq_32.metric_time__day - , subq_32.metric_time__week - , subq_32.metric_time__month - , subq_32.metric_time__quarter - , subq_32.metric_time__year - , subq_32.metric_time__extract_year - , subq_32.metric_time__extract_quarter - , subq_32.metric_time__extract_month - , subq_32.metric_time__extract_day - , subq_32.metric_time__extract_dow - , subq_32.metric_time__extract_doy - , subq_32.listing - , subq_32.guest - , subq_32.host - , subq_32.booking__listing - , subq_32.booking__guest - , subq_32.booking__host - , subq_32.is_instant - , subq_32.booking__is_instant - , subq_32.bookings - , subq_32.instant_bookings - , subq_32.booking_value - , subq_32.max_booking_value - , subq_32.min_booking_value - , subq_32.bookers - , subq_32.average_booking_value - , subq_32.referred_bookings - , subq_32.median_booking_value - , subq_32.booking_value_p99 - , subq_32.discrete_booking_value_p99 - , subq_32.approximate_continuous_booking_value_p99 - , subq_32.approximate_discrete_booking_value_p99 + subq_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.metric_time__day + , subq_20.metric_time__week + , subq_20.metric_time__month + , subq_20.metric_time__quarter + , subq_20.metric_time__year + , subq_20.metric_time__extract_year + , subq_20.metric_time__extract_quarter + , subq_20.metric_time__extract_month + , subq_20.metric_time__extract_day + , subq_20.metric_time__extract_dow + , subq_20.metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_31.ds__day - , subq_31.ds__week - , subq_31.ds__month - , subq_31.ds__quarter - , subq_31.ds__year - , subq_31.ds__extract_year - , subq_31.ds__extract_quarter - , subq_31.ds__extract_month - , subq_31.ds__extract_day - , subq_31.ds__extract_dow - , subq_31.ds__extract_doy - , subq_31.ds_partitioned__day - , subq_31.ds_partitioned__week - , subq_31.ds_partitioned__month - , subq_31.ds_partitioned__quarter - , subq_31.ds_partitioned__year - , subq_31.ds_partitioned__extract_year - , subq_31.ds_partitioned__extract_quarter - , subq_31.ds_partitioned__extract_month - , subq_31.ds_partitioned__extract_day - , subq_31.ds_partitioned__extract_dow - , subq_31.ds_partitioned__extract_doy - , subq_31.paid_at__day - , subq_31.paid_at__week - , subq_31.paid_at__month - , subq_31.paid_at__quarter - , subq_31.paid_at__year - , subq_31.paid_at__extract_year - , subq_31.paid_at__extract_quarter - , subq_31.paid_at__extract_month - , subq_31.paid_at__extract_day - , subq_31.paid_at__extract_dow - , subq_31.paid_at__extract_doy - , subq_31.booking__ds__day - , subq_31.booking__ds__week - , subq_31.booking__ds__month - , subq_31.booking__ds__quarter - , subq_31.booking__ds__year - , subq_31.booking__ds__extract_year - , subq_31.booking__ds__extract_quarter - , subq_31.booking__ds__extract_month - , subq_31.booking__ds__extract_day - , subq_31.booking__ds__extract_dow - , subq_31.booking__ds__extract_doy - , subq_31.booking__ds_partitioned__day - , subq_31.booking__ds_partitioned__week - , subq_31.booking__ds_partitioned__month - , subq_31.booking__ds_partitioned__quarter - , subq_31.booking__ds_partitioned__year - , subq_31.booking__ds_partitioned__extract_year - , subq_31.booking__ds_partitioned__extract_quarter - , subq_31.booking__ds_partitioned__extract_month - , subq_31.booking__ds_partitioned__extract_day - , subq_31.booking__ds_partitioned__extract_dow - , subq_31.booking__ds_partitioned__extract_doy - , subq_31.booking__paid_at__day - , subq_31.booking__paid_at__week - , subq_31.booking__paid_at__month - , subq_31.booking__paid_at__quarter - , subq_31.booking__paid_at__year - , subq_31.booking__paid_at__extract_year - , subq_31.booking__paid_at__extract_quarter - , subq_31.booking__paid_at__extract_month - , subq_31.booking__paid_at__extract_day - , subq_31.booking__paid_at__extract_dow - , subq_31.booking__paid_at__extract_doy - , subq_31.ds__day AS metric_time__day - , subq_31.ds__week AS metric_time__week - , subq_31.ds__month AS metric_time__month - , subq_31.ds__quarter AS metric_time__quarter - , subq_31.ds__year AS metric_time__year - , subq_31.ds__extract_year AS metric_time__extract_year - , subq_31.ds__extract_quarter AS metric_time__extract_quarter - , subq_31.ds__extract_month AS metric_time__extract_month - , subq_31.ds__extract_day AS metric_time__extract_day - , subq_31.ds__extract_dow AS metric_time__extract_dow - , subq_31.ds__extract_doy AS metric_time__extract_doy - , subq_31.listing - , subq_31.guest - , subq_31.host - , subq_31.booking__listing - , subq_31.booking__guest - , subq_31.booking__host - , subq_31.is_instant - , subq_31.booking__is_instant - , subq_31.bookings - , subq_31.instant_bookings - , subq_31.booking_value - , subq_31.max_booking_value - , subq_31.min_booking_value - , subq_31.bookers - , subq_31.average_booking_value - , subq_31.referred_bookings - , subq_31.median_booking_value - , subq_31.booking_value_p99 - , subq_31.discrete_booking_value_p99 - , subq_31.approximate_continuous_booking_value_p99 - , subq_31.approximate_discrete_booking_value_p99 + subq_19.ds__day + , subq_19.ds__week + , subq_19.ds__month + , subq_19.ds__quarter + , subq_19.ds__year + , subq_19.ds__extract_year + , subq_19.ds__extract_quarter + , subq_19.ds__extract_month + , subq_19.ds__extract_day + , subq_19.ds__extract_dow + , subq_19.ds__extract_doy + , subq_19.ds_partitioned__day + , subq_19.ds_partitioned__week + , subq_19.ds_partitioned__month + , subq_19.ds_partitioned__quarter + , subq_19.ds_partitioned__year + , subq_19.ds_partitioned__extract_year + , subq_19.ds_partitioned__extract_quarter + , subq_19.ds_partitioned__extract_month + , subq_19.ds_partitioned__extract_day + , subq_19.ds_partitioned__extract_dow + , subq_19.ds_partitioned__extract_doy + , subq_19.paid_at__day + , subq_19.paid_at__week + , subq_19.paid_at__month + , subq_19.paid_at__quarter + , subq_19.paid_at__year + , subq_19.paid_at__extract_year + , subq_19.paid_at__extract_quarter + , subq_19.paid_at__extract_month + , subq_19.paid_at__extract_day + , subq_19.paid_at__extract_dow + , subq_19.paid_at__extract_doy + , subq_19.booking__ds__day + , subq_19.booking__ds__week + , subq_19.booking__ds__month + , subq_19.booking__ds__quarter + , subq_19.booking__ds__year + , subq_19.booking__ds__extract_year + , subq_19.booking__ds__extract_quarter + , subq_19.booking__ds__extract_month + , subq_19.booking__ds__extract_day + , subq_19.booking__ds__extract_dow + , subq_19.booking__ds__extract_doy + , subq_19.booking__ds_partitioned__day + , subq_19.booking__ds_partitioned__week + , subq_19.booking__ds_partitioned__month + , subq_19.booking__ds_partitioned__quarter + , subq_19.booking__ds_partitioned__year + , subq_19.booking__ds_partitioned__extract_year + , subq_19.booking__ds_partitioned__extract_quarter + , subq_19.booking__ds_partitioned__extract_month + , subq_19.booking__ds_partitioned__extract_day + , subq_19.booking__ds_partitioned__extract_dow + , subq_19.booking__ds_partitioned__extract_doy + , subq_19.booking__paid_at__day + , subq_19.booking__paid_at__week + , subq_19.booking__paid_at__month + , subq_19.booking__paid_at__quarter + , subq_19.booking__paid_at__year + , subq_19.booking__paid_at__extract_year + , subq_19.booking__paid_at__extract_quarter + , subq_19.booking__paid_at__extract_month + , subq_19.booking__paid_at__extract_day + , subq_19.booking__paid_at__extract_dow + , subq_19.booking__paid_at__extract_doy + , subq_19.ds__day AS metric_time__day + , subq_19.ds__week AS metric_time__week + , subq_19.ds__month AS metric_time__month + , subq_19.ds__quarter AS metric_time__quarter + , subq_19.ds__year AS metric_time__year + , subq_19.ds__extract_year AS metric_time__extract_year + , subq_19.ds__extract_quarter AS metric_time__extract_quarter + , subq_19.ds__extract_month AS metric_time__extract_month + , subq_19.ds__extract_day AS metric_time__extract_day + , subq_19.ds__extract_dow AS metric_time__extract_dow + , subq_19.ds__extract_doy AS metric_time__extract_doy + , subq_19.listing + , subq_19.guest + , subq_19.host + , subq_19.booking__listing + , subq_19.booking__guest + , subq_19.booking__host + , subq_19.is_instant + , subq_19.booking__is_instant + , subq_19.bookings + , subq_19.instant_bookings + , subq_19.booking_value + , subq_19.max_booking_value + , subq_19.min_booking_value + , subq_19.bookers + , subq_19.average_booking_value + , subq_19.referred_bookings + , subq_19.median_booking_value + , subq_19.booking_value_p99 + , subq_19.discrete_booking_value_p99 + , subq_19.approximate_continuous_booking_value_p99 + , subq_19.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -825,86 +825,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_31 - ) subq_32 + ) subq_19 + ) subq_20 WHERE booking__is_instant - ) subq_33 - ) subq_34 + ) subq_21 + ) subq_22 LEFT OUTER JOIN ( -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_36.listing - , subq_36.is_lux_latest + subq_24.listing + , subq_24.is_lux_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_35.ds__day - , subq_35.ds__week - , subq_35.ds__month - , subq_35.ds__quarter - , subq_35.ds__year - , subq_35.ds__extract_year - , subq_35.ds__extract_quarter - , subq_35.ds__extract_month - , subq_35.ds__extract_day - , subq_35.ds__extract_dow - , subq_35.ds__extract_doy - , subq_35.created_at__day - , subq_35.created_at__week - , subq_35.created_at__month - , subq_35.created_at__quarter - , subq_35.created_at__year - , subq_35.created_at__extract_year - , subq_35.created_at__extract_quarter - , subq_35.created_at__extract_month - , subq_35.created_at__extract_day - , subq_35.created_at__extract_dow - , subq_35.created_at__extract_doy - , subq_35.listing__ds__day - , subq_35.listing__ds__week - , subq_35.listing__ds__month - , subq_35.listing__ds__quarter - , subq_35.listing__ds__year - , subq_35.listing__ds__extract_year - , subq_35.listing__ds__extract_quarter - , subq_35.listing__ds__extract_month - , subq_35.listing__ds__extract_day - , subq_35.listing__ds__extract_dow - , subq_35.listing__ds__extract_doy - , subq_35.listing__created_at__day - , subq_35.listing__created_at__week - , subq_35.listing__created_at__month - , subq_35.listing__created_at__quarter - , subq_35.listing__created_at__year - , subq_35.listing__created_at__extract_year - , subq_35.listing__created_at__extract_quarter - , subq_35.listing__created_at__extract_month - , subq_35.listing__created_at__extract_day - , subq_35.listing__created_at__extract_dow - , subq_35.listing__created_at__extract_doy - , subq_35.ds__day AS metric_time__day - , subq_35.ds__week AS metric_time__week - , subq_35.ds__month AS metric_time__month - , subq_35.ds__quarter AS metric_time__quarter - , subq_35.ds__year AS metric_time__year - , subq_35.ds__extract_year AS metric_time__extract_year - , subq_35.ds__extract_quarter AS metric_time__extract_quarter - , subq_35.ds__extract_month AS metric_time__extract_month - , subq_35.ds__extract_day AS metric_time__extract_day - , subq_35.ds__extract_dow AS metric_time__extract_dow - , subq_35.ds__extract_doy AS metric_time__extract_doy - , subq_35.listing - , subq_35.user - , subq_35.listing__user - , subq_35.country_latest - , subq_35.is_lux_latest - , subq_35.capacity_latest - , subq_35.listing__country_latest - , subq_35.listing__is_lux_latest - , subq_35.listing__capacity_latest - , subq_35.listings - , subq_35.largest_listing - , subq_35.smallest_listing + subq_23.ds__day + , subq_23.ds__week + , subq_23.ds__month + , subq_23.ds__quarter + , subq_23.ds__year + , subq_23.ds__extract_year + , subq_23.ds__extract_quarter + , subq_23.ds__extract_month + , subq_23.ds__extract_day + , subq_23.ds__extract_dow + , subq_23.ds__extract_doy + , subq_23.created_at__day + , subq_23.created_at__week + , subq_23.created_at__month + , subq_23.created_at__quarter + , subq_23.created_at__year + , subq_23.created_at__extract_year + , subq_23.created_at__extract_quarter + , subq_23.created_at__extract_month + , subq_23.created_at__extract_day + , subq_23.created_at__extract_dow + , subq_23.created_at__extract_doy + , subq_23.listing__ds__day + , subq_23.listing__ds__week + , subq_23.listing__ds__month + , subq_23.listing__ds__quarter + , subq_23.listing__ds__year + , subq_23.listing__ds__extract_year + , subq_23.listing__ds__extract_quarter + , subq_23.listing__ds__extract_month + , subq_23.listing__ds__extract_day + , subq_23.listing__ds__extract_dow + , subq_23.listing__ds__extract_doy + , subq_23.listing__created_at__day + , subq_23.listing__created_at__week + , subq_23.listing__created_at__month + , subq_23.listing__created_at__quarter + , subq_23.listing__created_at__year + , subq_23.listing__created_at__extract_year + , subq_23.listing__created_at__extract_quarter + , subq_23.listing__created_at__extract_month + , subq_23.listing__created_at__extract_day + , subq_23.listing__created_at__extract_dow + , subq_23.listing__created_at__extract_doy + , subq_23.ds__day AS metric_time__day + , subq_23.ds__week AS metric_time__week + , subq_23.ds__month AS metric_time__month + , subq_23.ds__quarter AS metric_time__quarter + , subq_23.ds__year AS metric_time__year + , subq_23.ds__extract_year AS metric_time__extract_year + , subq_23.ds__extract_quarter AS metric_time__extract_quarter + , subq_23.ds__extract_month AS metric_time__extract_month + , subq_23.ds__extract_day AS metric_time__extract_day + , subq_23.ds__extract_dow AS metric_time__extract_dow + , subq_23.ds__extract_doy AS metric_time__extract_doy + , subq_23.listing + , subq_23.user + , subq_23.listing__user + , subq_23.country_latest + , subq_23.is_lux_latest + , subq_23.capacity_latest + , subq_23.listing__country_latest + , subq_23.listing__is_lux_latest + , subq_23.listing__capacity_latest + , subq_23.listings + , subq_23.largest_listing + , subq_23.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -965,242 +965,242 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_35 - ) subq_36 - ) subq_37 + ) subq_23 + ) subq_24 + ) subq_25 ON - subq_34.listing = subq_37.listing - ) subq_38 - ) subq_39 + subq_22.listing = subq_25.listing + ) subq_26 + ) subq_27 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_40 - ) subq_41 - ) subq_42 - ) subq_43 + ) subq_28 + ) subq_29 + ) subq_30 + ) subq_31 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_50.booking_value + subq_38.booking_value FROM ( -- Aggregate Measures SELECT - SUM(subq_49.booking_value) AS booking_value + SUM(subq_37.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value',] SELECT - subq_48.booking_value + subq_36.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_47.booking__is_instant - , subq_47.booking_value + subq_35.booking__is_instant + , subq_35.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT - subq_46.booking__is_instant - , subq_46.booking_value + subq_34.booking__is_instant + , subq_34.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_45.ds__day - , subq_45.ds__week - , subq_45.ds__month - , subq_45.ds__quarter - , subq_45.ds__year - , subq_45.ds__extract_year - , subq_45.ds__extract_quarter - , subq_45.ds__extract_month - , subq_45.ds__extract_day - , subq_45.ds__extract_dow - , subq_45.ds__extract_doy - , subq_45.ds_partitioned__day - , subq_45.ds_partitioned__week - , subq_45.ds_partitioned__month - , subq_45.ds_partitioned__quarter - , subq_45.ds_partitioned__year - , subq_45.ds_partitioned__extract_year - , subq_45.ds_partitioned__extract_quarter - , subq_45.ds_partitioned__extract_month - , subq_45.ds_partitioned__extract_day - , subq_45.ds_partitioned__extract_dow - , subq_45.ds_partitioned__extract_doy - , subq_45.paid_at__day - , subq_45.paid_at__week - , subq_45.paid_at__month - , subq_45.paid_at__quarter - , subq_45.paid_at__year - , subq_45.paid_at__extract_year - , subq_45.paid_at__extract_quarter - , subq_45.paid_at__extract_month - , subq_45.paid_at__extract_day - , subq_45.paid_at__extract_dow - , subq_45.paid_at__extract_doy - , subq_45.booking__ds__day - , subq_45.booking__ds__week - , subq_45.booking__ds__month - , subq_45.booking__ds__quarter - , subq_45.booking__ds__year - , subq_45.booking__ds__extract_year - , subq_45.booking__ds__extract_quarter - , subq_45.booking__ds__extract_month - , subq_45.booking__ds__extract_day - , subq_45.booking__ds__extract_dow - , subq_45.booking__ds__extract_doy - , subq_45.booking__ds_partitioned__day - , subq_45.booking__ds_partitioned__week - , subq_45.booking__ds_partitioned__month - , subq_45.booking__ds_partitioned__quarter - , subq_45.booking__ds_partitioned__year - , subq_45.booking__ds_partitioned__extract_year - , subq_45.booking__ds_partitioned__extract_quarter - , subq_45.booking__ds_partitioned__extract_month - , subq_45.booking__ds_partitioned__extract_day - , subq_45.booking__ds_partitioned__extract_dow - , subq_45.booking__ds_partitioned__extract_doy - , subq_45.booking__paid_at__day - , subq_45.booking__paid_at__week - , subq_45.booking__paid_at__month - , subq_45.booking__paid_at__quarter - , subq_45.booking__paid_at__year - , subq_45.booking__paid_at__extract_year - , subq_45.booking__paid_at__extract_quarter - , subq_45.booking__paid_at__extract_month - , subq_45.booking__paid_at__extract_day - , subq_45.booking__paid_at__extract_dow - , subq_45.booking__paid_at__extract_doy - , subq_45.metric_time__day - , subq_45.metric_time__week - , subq_45.metric_time__month - , subq_45.metric_time__quarter - , subq_45.metric_time__year - , subq_45.metric_time__extract_year - , subq_45.metric_time__extract_quarter - , subq_45.metric_time__extract_month - , subq_45.metric_time__extract_day - , subq_45.metric_time__extract_dow - , subq_45.metric_time__extract_doy - , subq_45.listing - , subq_45.guest - , subq_45.host - , subq_45.booking__listing - , subq_45.booking__guest - , subq_45.booking__host - , subq_45.is_instant - , subq_45.booking__is_instant - , subq_45.bookings - , subq_45.instant_bookings - , subq_45.booking_value - , subq_45.max_booking_value - , subq_45.min_booking_value - , subq_45.bookers - , subq_45.average_booking_value - , subq_45.referred_bookings - , subq_45.median_booking_value - , subq_45.booking_value_p99 - , subq_45.discrete_booking_value_p99 - , subq_45.approximate_continuous_booking_value_p99 - , subq_45.approximate_discrete_booking_value_p99 + subq_33.ds__day + , subq_33.ds__week + , subq_33.ds__month + , subq_33.ds__quarter + , subq_33.ds__year + , subq_33.ds__extract_year + , subq_33.ds__extract_quarter + , subq_33.ds__extract_month + , subq_33.ds__extract_day + , subq_33.ds__extract_dow + , subq_33.ds__extract_doy + , subq_33.ds_partitioned__day + , subq_33.ds_partitioned__week + , subq_33.ds_partitioned__month + , subq_33.ds_partitioned__quarter + , subq_33.ds_partitioned__year + , subq_33.ds_partitioned__extract_year + , subq_33.ds_partitioned__extract_quarter + , subq_33.ds_partitioned__extract_month + , subq_33.ds_partitioned__extract_day + , subq_33.ds_partitioned__extract_dow + , subq_33.ds_partitioned__extract_doy + , subq_33.paid_at__day + , subq_33.paid_at__week + , subq_33.paid_at__month + , subq_33.paid_at__quarter + , subq_33.paid_at__year + , subq_33.paid_at__extract_year + , subq_33.paid_at__extract_quarter + , subq_33.paid_at__extract_month + , subq_33.paid_at__extract_day + , subq_33.paid_at__extract_dow + , subq_33.paid_at__extract_doy + , subq_33.booking__ds__day + , subq_33.booking__ds__week + , subq_33.booking__ds__month + , subq_33.booking__ds__quarter + , subq_33.booking__ds__year + , subq_33.booking__ds__extract_year + , subq_33.booking__ds__extract_quarter + , subq_33.booking__ds__extract_month + , subq_33.booking__ds__extract_day + , subq_33.booking__ds__extract_dow + , subq_33.booking__ds__extract_doy + , subq_33.booking__ds_partitioned__day + , subq_33.booking__ds_partitioned__week + , subq_33.booking__ds_partitioned__month + , subq_33.booking__ds_partitioned__quarter + , subq_33.booking__ds_partitioned__year + , subq_33.booking__ds_partitioned__extract_year + , subq_33.booking__ds_partitioned__extract_quarter + , subq_33.booking__ds_partitioned__extract_month + , subq_33.booking__ds_partitioned__extract_day + , subq_33.booking__ds_partitioned__extract_dow + , subq_33.booking__ds_partitioned__extract_doy + , subq_33.booking__paid_at__day + , subq_33.booking__paid_at__week + , subq_33.booking__paid_at__month + , subq_33.booking__paid_at__quarter + , subq_33.booking__paid_at__year + , subq_33.booking__paid_at__extract_year + , subq_33.booking__paid_at__extract_quarter + , subq_33.booking__paid_at__extract_month + , subq_33.booking__paid_at__extract_day + , subq_33.booking__paid_at__extract_dow + , subq_33.booking__paid_at__extract_doy + , subq_33.metric_time__day + , subq_33.metric_time__week + , subq_33.metric_time__month + , subq_33.metric_time__quarter + , subq_33.metric_time__year + , subq_33.metric_time__extract_year + , subq_33.metric_time__extract_quarter + , subq_33.metric_time__extract_month + , subq_33.metric_time__extract_day + , subq_33.metric_time__extract_dow + , subq_33.metric_time__extract_doy + , subq_33.listing + , subq_33.guest + , subq_33.host + , subq_33.booking__listing + , subq_33.booking__guest + , subq_33.booking__host + , subq_33.is_instant + , subq_33.booking__is_instant + , subq_33.bookings + , subq_33.instant_bookings + , subq_33.booking_value + , subq_33.max_booking_value + , subq_33.min_booking_value + , subq_33.bookers + , subq_33.average_booking_value + , subq_33.referred_bookings + , subq_33.median_booking_value + , subq_33.booking_value_p99 + , subq_33.discrete_booking_value_p99 + , subq_33.approximate_continuous_booking_value_p99 + , subq_33.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_44.ds__day - , subq_44.ds__week - , subq_44.ds__month - , subq_44.ds__quarter - , subq_44.ds__year - , subq_44.ds__extract_year - , subq_44.ds__extract_quarter - , subq_44.ds__extract_month - , subq_44.ds__extract_day - , subq_44.ds__extract_dow - , subq_44.ds__extract_doy - , subq_44.ds_partitioned__day - , subq_44.ds_partitioned__week - , subq_44.ds_partitioned__month - , subq_44.ds_partitioned__quarter - , subq_44.ds_partitioned__year - , subq_44.ds_partitioned__extract_year - , subq_44.ds_partitioned__extract_quarter - , subq_44.ds_partitioned__extract_month - , subq_44.ds_partitioned__extract_day - , subq_44.ds_partitioned__extract_dow - , subq_44.ds_partitioned__extract_doy - , subq_44.paid_at__day - , subq_44.paid_at__week - , subq_44.paid_at__month - , subq_44.paid_at__quarter - , subq_44.paid_at__year - , subq_44.paid_at__extract_year - , subq_44.paid_at__extract_quarter - , subq_44.paid_at__extract_month - , subq_44.paid_at__extract_day - , subq_44.paid_at__extract_dow - , subq_44.paid_at__extract_doy - , subq_44.booking__ds__day - , subq_44.booking__ds__week - , subq_44.booking__ds__month - , subq_44.booking__ds__quarter - , subq_44.booking__ds__year - , subq_44.booking__ds__extract_year - , subq_44.booking__ds__extract_quarter - , subq_44.booking__ds__extract_month - , subq_44.booking__ds__extract_day - , subq_44.booking__ds__extract_dow - , subq_44.booking__ds__extract_doy - , subq_44.booking__ds_partitioned__day - , subq_44.booking__ds_partitioned__week - , subq_44.booking__ds_partitioned__month - , subq_44.booking__ds_partitioned__quarter - , subq_44.booking__ds_partitioned__year - , subq_44.booking__ds_partitioned__extract_year - , subq_44.booking__ds_partitioned__extract_quarter - , subq_44.booking__ds_partitioned__extract_month - , subq_44.booking__ds_partitioned__extract_day - , subq_44.booking__ds_partitioned__extract_dow - , subq_44.booking__ds_partitioned__extract_doy - , subq_44.booking__paid_at__day - , subq_44.booking__paid_at__week - , subq_44.booking__paid_at__month - , subq_44.booking__paid_at__quarter - , subq_44.booking__paid_at__year - , subq_44.booking__paid_at__extract_year - , subq_44.booking__paid_at__extract_quarter - , subq_44.booking__paid_at__extract_month - , subq_44.booking__paid_at__extract_day - , subq_44.booking__paid_at__extract_dow - , subq_44.booking__paid_at__extract_doy - , subq_44.ds__day AS metric_time__day - , subq_44.ds__week AS metric_time__week - , subq_44.ds__month AS metric_time__month - , subq_44.ds__quarter AS metric_time__quarter - , subq_44.ds__year AS metric_time__year - , subq_44.ds__extract_year AS metric_time__extract_year - , subq_44.ds__extract_quarter AS metric_time__extract_quarter - , subq_44.ds__extract_month AS metric_time__extract_month - , subq_44.ds__extract_day AS metric_time__extract_day - , subq_44.ds__extract_dow AS metric_time__extract_dow - , subq_44.ds__extract_doy AS metric_time__extract_doy - , subq_44.listing - , subq_44.guest - , subq_44.host - , subq_44.booking__listing - , subq_44.booking__guest - , subq_44.booking__host - , subq_44.is_instant - , subq_44.booking__is_instant - , subq_44.bookings - , subq_44.instant_bookings - , subq_44.booking_value - , subq_44.max_booking_value - , subq_44.min_booking_value - , subq_44.bookers - , subq_44.average_booking_value - , subq_44.referred_bookings - , subq_44.median_booking_value - , subq_44.booking_value_p99 - , subq_44.discrete_booking_value_p99 - , subq_44.approximate_continuous_booking_value_p99 - , subq_44.approximate_discrete_booking_value_p99 + subq_32.ds__day + , subq_32.ds__week + , subq_32.ds__month + , subq_32.ds__quarter + , subq_32.ds__year + , subq_32.ds__extract_year + , subq_32.ds__extract_quarter + , subq_32.ds__extract_month + , subq_32.ds__extract_day + , subq_32.ds__extract_dow + , subq_32.ds__extract_doy + , subq_32.ds_partitioned__day + , subq_32.ds_partitioned__week + , subq_32.ds_partitioned__month + , subq_32.ds_partitioned__quarter + , subq_32.ds_partitioned__year + , subq_32.ds_partitioned__extract_year + , subq_32.ds_partitioned__extract_quarter + , subq_32.ds_partitioned__extract_month + , subq_32.ds_partitioned__extract_day + , subq_32.ds_partitioned__extract_dow + , subq_32.ds_partitioned__extract_doy + , subq_32.paid_at__day + , subq_32.paid_at__week + , subq_32.paid_at__month + , subq_32.paid_at__quarter + , subq_32.paid_at__year + , subq_32.paid_at__extract_year + , subq_32.paid_at__extract_quarter + , subq_32.paid_at__extract_month + , subq_32.paid_at__extract_day + , subq_32.paid_at__extract_dow + , subq_32.paid_at__extract_doy + , subq_32.booking__ds__day + , subq_32.booking__ds__week + , subq_32.booking__ds__month + , subq_32.booking__ds__quarter + , subq_32.booking__ds__year + , subq_32.booking__ds__extract_year + , subq_32.booking__ds__extract_quarter + , subq_32.booking__ds__extract_month + , subq_32.booking__ds__extract_day + , subq_32.booking__ds__extract_dow + , subq_32.booking__ds__extract_doy + , subq_32.booking__ds_partitioned__day + , subq_32.booking__ds_partitioned__week + , subq_32.booking__ds_partitioned__month + , subq_32.booking__ds_partitioned__quarter + , subq_32.booking__ds_partitioned__year + , subq_32.booking__ds_partitioned__extract_year + , subq_32.booking__ds_partitioned__extract_quarter + , subq_32.booking__ds_partitioned__extract_month + , subq_32.booking__ds_partitioned__extract_day + , subq_32.booking__ds_partitioned__extract_dow + , subq_32.booking__ds_partitioned__extract_doy + , subq_32.booking__paid_at__day + , subq_32.booking__paid_at__week + , subq_32.booking__paid_at__month + , subq_32.booking__paid_at__quarter + , subq_32.booking__paid_at__year + , subq_32.booking__paid_at__extract_year + , subq_32.booking__paid_at__extract_quarter + , subq_32.booking__paid_at__extract_month + , subq_32.booking__paid_at__extract_day + , subq_32.booking__paid_at__extract_dow + , subq_32.booking__paid_at__extract_doy + , subq_32.ds__day AS metric_time__day + , subq_32.ds__week AS metric_time__week + , subq_32.ds__month AS metric_time__month + , subq_32.ds__quarter AS metric_time__quarter + , subq_32.ds__year AS metric_time__year + , subq_32.ds__extract_year AS metric_time__extract_year + , subq_32.ds__extract_quarter AS metric_time__extract_quarter + , subq_32.ds__extract_month AS metric_time__extract_month + , subq_32.ds__extract_day AS metric_time__extract_day + , subq_32.ds__extract_dow AS metric_time__extract_dow + , subq_32.ds__extract_doy AS metric_time__extract_doy + , subq_32.listing + , subq_32.guest + , subq_32.host + , subq_32.booking__listing + , subq_32.booking__guest + , subq_32.booking__host + , subq_32.is_instant + , subq_32.booking__is_instant + , subq_32.bookings + , subq_32.instant_bookings + , subq_32.booking_value + , subq_32.max_booking_value + , subq_32.min_booking_value + , subq_32.bookers + , subq_32.average_booking_value + , subq_32.referred_bookings + , subq_32.median_booking_value + , subq_32.booking_value_p99 + , subq_32.discrete_booking_value_p99 + , subq_32.approximate_continuous_booking_value_p99 + , subq_32.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -1293,15 +1293,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_44 - ) subq_45 + ) subq_32 + ) subq_33 WHERE booking__is_instant - ) subq_46 - ) subq_47 + ) subq_34 + ) subq_35 WHERE booking__is_instant - ) subq_48 - ) subq_49 - ) subq_50 - ) subq_51 - ) subq_52 -) subq_53 + ) subq_36 + ) subq_37 + ) subq_38 + ) subq_39 + ) subq_40 +) subq_41 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/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 a0fdc735bd..60a09b752b 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_66.average_booking_value) AS average_booking_value - , MAX(subq_79.bookings) AS bookings - , MAX(subq_87.booking_value) AS booking_value + MAX(subq_54.average_booking_value) AS average_booking_value + , MAX(subq_67.bookings) AS bookings + , MAX(subq_75.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value',] @@ -22,9 +22,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_57.booking__is_instant AS booking__is_instant + subq_45.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_57.average_booking_value AS average_booking_value + , subq_45.average_booking_value AS average_booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] @@ -40,16 +40,16 @@ FROM ( , is_instant AS booking__is_instant , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_55 + ) subq_43 WHERE booking__is_instant - ) subq_57 + ) subq_45 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_57.listing = listings_latest_src_28000.listing_id - ) subq_62 + subq_45.listing = listings_latest_src_28000.listing_id + ) subq_50 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_66 + ) subq_54 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings',] @@ -61,9 +61,9 @@ FROM ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_70.booking__is_instant AS booking__is_instant + subq_58.booking__is_instant AS booking__is_instant , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_70.bookings AS bookings + , subq_58.bookings AS bookings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] @@ -79,16 +79,16 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_68 + ) subq_56 WHERE booking__is_instant - ) subq_70 + ) subq_58 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_70.listing = listings_latest_src_28000.listing_id - ) subq_75 + subq_58.listing = listings_latest_src_28000.listing_id + ) subq_63 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_79 + ) subq_67 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -109,10 +109,10 @@ FROM ( is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_81 + ) subq_69 WHERE booking__is_instant - ) subq_83 + ) subq_71 WHERE booking__is_instant - ) subq_87 - ) subq_88 -) subq_89 + ) subq_75 + ) subq_76 +) subq_77 diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0.sql index b76cec7e4c..0c1597746c 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -1,127 +1,127 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_4.listing__is_lux_latest + , subq_4.user__home_state_latest FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.created_at__day + , subq_3.created_at__week + , subq_3.created_at__month + , subq_3.created_at__quarter + , subq_3.created_at__year + , subq_3.created_at__extract_year + , subq_3.created_at__extract_quarter + , subq_3.created_at__extract_month + , subq_3.created_at__extract_day + , subq_3.created_at__extract_dow + , subq_3.created_at__extract_doy + , subq_3.listing__ds__day + , subq_3.listing__ds__week + , subq_3.listing__ds__month + , subq_3.listing__ds__quarter + , subq_3.listing__ds__year + , subq_3.listing__ds__extract_year + , subq_3.listing__ds__extract_quarter + , subq_3.listing__ds__extract_month + , subq_3.listing__ds__extract_day + , subq_3.listing__ds__extract_dow + , subq_3.listing__ds__extract_doy + , subq_3.listing__created_at__day + , subq_3.listing__created_at__week + , subq_3.listing__created_at__month + , subq_3.listing__created_at__quarter + , subq_3.listing__created_at__year + , subq_3.listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month + , subq_3.listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy + , subq_3.listing + , subq_3.user + , subq_3.listing__user + , subq_3.country_latest + , subq_3.is_lux_latest + , subq_3.capacity_latest + , subq_3.listing__country_latest + , subq_3.listing__is_lux_latest + , subq_3.listing__capacity_latest + , subq_3.user__home_state_latest + , subq_3.listings + , subq_3.largest_listing + , subq_3.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.created_at__day AS created_at__day - , subq_2.created_at__week AS created_at__week - , subq_2.created_at__month AS created_at__month - , subq_2.created_at__quarter AS created_at__quarter - , subq_2.created_at__year AS created_at__year - , subq_2.created_at__extract_year AS created_at__extract_year - , subq_2.created_at__extract_quarter AS created_at__extract_quarter - , subq_2.created_at__extract_month AS created_at__extract_month - , subq_2.created_at__extract_day AS created_at__extract_day - , subq_2.created_at__extract_dow AS created_at__extract_dow - , subq_2.created_at__extract_doy AS created_at__extract_doy - , subq_2.listing__ds__day AS listing__ds__day - , subq_2.listing__ds__week AS listing__ds__week - , subq_2.listing__ds__month AS listing__ds__month - , subq_2.listing__ds__quarter AS listing__ds__quarter - , subq_2.listing__ds__year AS listing__ds__year - , subq_2.listing__ds__extract_year AS listing__ds__extract_year - , subq_2.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_2.listing__ds__extract_month AS listing__ds__extract_month - , subq_2.listing__ds__extract_day AS listing__ds__extract_day - , subq_2.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_2.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_2.listing__created_at__day AS listing__created_at__day - , subq_2.listing__created_at__week AS listing__created_at__week - , subq_2.listing__created_at__month AS listing__created_at__month - , subq_2.listing__created_at__quarter AS listing__created_at__quarter - , subq_2.listing__created_at__year AS listing__created_at__year - , subq_2.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_2.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_2.listing AS listing - , subq_2.user AS user - , subq_2.listing__user AS listing__user - , subq_2.country_latest AS country_latest - , subq_2.is_lux_latest AS is_lux_latest - , subq_2.capacity_latest AS capacity_latest - , subq_2.listing__country_latest AS listing__country_latest - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_5.home_state_latest AS user__home_state_latest - , subq_2.listings AS listings - , subq_2.largest_listing AS largest_listing - , subq_2.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_2.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -182,78 +182,48 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_1.user + , subq_1.home_state_latest FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.ds_latest__day - , subq_3.ds_latest__week - , subq_3.ds_latest__month - , subq_3.ds_latest__quarter - , subq_3.ds_latest__year - , subq_3.ds_latest__extract_year - , subq_3.ds_latest__extract_quarter - , subq_3.ds_latest__extract_month - , subq_3.ds_latest__extract_day - , subq_3.ds_latest__extract_dow - , subq_3.ds_latest__extract_doy - , subq_3.user__ds_latest__day - , subq_3.user__ds_latest__week - , subq_3.user__ds_latest__month - , subq_3.user__ds_latest__quarter - , subq_3.user__ds_latest__year - , subq_3.user__ds_latest__extract_year - , subq_3.user__ds_latest__extract_quarter - , subq_3.user__ds_latest__extract_month - , subq_3.user__ds_latest__extract_day - , subq_3.user__ds_latest__extract_dow - , subq_3.user__ds_latest__extract_doy - , subq_3.user - , subq_3.home_state_latest - , subq_3.user__home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC(users_latest_src_28000.ds, day) AS ds_latest__day - , DATE_TRUNC(users_latest_src_28000.ds, isoweek) AS ds_latest__week - , DATE_TRUNC(users_latest_src_28000.ds, month) AS ds_latest__month - , DATE_TRUNC(users_latest_src_28000.ds, quarter) AS ds_latest__quarter - , DATE_TRUNC(users_latest_src_28000.ds, year) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28000.ds) - 1) AS ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC(users_latest_src_28000.ds, day) AS user__ds_latest__day - , DATE_TRUNC(users_latest_src_28000.ds, isoweek) AS user__ds_latest__week - , DATE_TRUNC(users_latest_src_28000.ds, month) AS user__ds_latest__month - , DATE_TRUNC(users_latest_src_28000.ds, quarter) AS user__ds_latest__quarter - , DATE_TRUNC(users_latest_src_28000.ds, year) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28000.ds) - 1) AS user__ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - WHERE user__home_state_latest = 'us' - ) subq_4 - ) subq_5 + DATE_TRUNC(users_latest_src_28000.ds, day) AS ds_latest__day + , DATE_TRUNC(users_latest_src_28000.ds, isoweek) AS ds_latest__week + , DATE_TRUNC(users_latest_src_28000.ds, month) AS ds_latest__month + , DATE_TRUNC(users_latest_src_28000.ds, quarter) AS ds_latest__quarter + , DATE_TRUNC(users_latest_src_28000.ds, year) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28000.ds) - 1) AS ds_latest__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_28000.ds) AS ds_latest__extract_doy + , users_latest_src_28000.home_state_latest + , DATE_TRUNC(users_latest_src_28000.ds, day) AS user__ds_latest__day + , DATE_TRUNC(users_latest_src_28000.ds, isoweek) AS user__ds_latest__week + , DATE_TRUNC(users_latest_src_28000.ds, month) AS user__ds_latest__month + , DATE_TRUNC(users_latest_src_28000.ds, quarter) AS user__ds_latest__quarter + , DATE_TRUNC(users_latest_src_28000.ds, year) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28000.ds) - 1) AS user__ds_latest__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , users_latest_src_28000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_28000 + ) subq_1 + ) subq_2 ON - subq_2.user = subq_5.user - ) subq_6 + subq_0.user = subq_2.user + ) subq_3 WHERE user__home_state_latest = 'us' -) subq_7 +) subq_4 GROUP BY listing__is_lux_latest , user__home_state_latest diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index c77b46c217..e54eaffeb6 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/BigQuery/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -7,27 +7,13 @@ FROM ( -- Join Standard Outputs SELECT listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_11.home_state_latest AS user__home_state_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest FROM ***************************.dim_listings_latest listings_latest_src_28000 - FULL OUTER JOIN ( - -- Constrain Output with WHERE - -- Pass Only Elements: ['home_state_latest', 'user'] - SELECT - subq_9.user - , home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - home_state_latest - , home_state_latest AS user__home_state_latest - , user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_9 - WHERE user__home_state_latest = 'us' - ) subq_11 + FULL OUTER JOIN + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28000.user_id = subq_11.user -) subq_12 + listings_latest_src_28000.user_id = users_latest_src_28000.user_id +) subq_8 WHERE user__home_state_latest = 'us' GROUP BY listing__is_lux_latest diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0.sql index 88bb3740a1..90b66576dd 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -1,127 +1,127 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_4.listing__is_lux_latest + , subq_4.user__home_state_latest FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.created_at__day + , subq_3.created_at__week + , subq_3.created_at__month + , subq_3.created_at__quarter + , subq_3.created_at__year + , subq_3.created_at__extract_year + , subq_3.created_at__extract_quarter + , subq_3.created_at__extract_month + , subq_3.created_at__extract_day + , subq_3.created_at__extract_dow + , subq_3.created_at__extract_doy + , subq_3.listing__ds__day + , subq_3.listing__ds__week + , subq_3.listing__ds__month + , subq_3.listing__ds__quarter + , subq_3.listing__ds__year + , subq_3.listing__ds__extract_year + , subq_3.listing__ds__extract_quarter + , subq_3.listing__ds__extract_month + , subq_3.listing__ds__extract_day + , subq_3.listing__ds__extract_dow + , subq_3.listing__ds__extract_doy + , subq_3.listing__created_at__day + , subq_3.listing__created_at__week + , subq_3.listing__created_at__month + , subq_3.listing__created_at__quarter + , subq_3.listing__created_at__year + , subq_3.listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month + , subq_3.listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy + , subq_3.listing + , subq_3.user + , subq_3.listing__user + , subq_3.country_latest + , subq_3.is_lux_latest + , subq_3.capacity_latest + , subq_3.listing__country_latest + , subq_3.listing__is_lux_latest + , subq_3.listing__capacity_latest + , subq_3.user__home_state_latest + , subq_3.listings + , subq_3.largest_listing + , subq_3.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.created_at__day AS created_at__day - , subq_2.created_at__week AS created_at__week - , subq_2.created_at__month AS created_at__month - , subq_2.created_at__quarter AS created_at__quarter - , subq_2.created_at__year AS created_at__year - , subq_2.created_at__extract_year AS created_at__extract_year - , subq_2.created_at__extract_quarter AS created_at__extract_quarter - , subq_2.created_at__extract_month AS created_at__extract_month - , subq_2.created_at__extract_day AS created_at__extract_day - , subq_2.created_at__extract_dow AS created_at__extract_dow - , subq_2.created_at__extract_doy AS created_at__extract_doy - , subq_2.listing__ds__day AS listing__ds__day - , subq_2.listing__ds__week AS listing__ds__week - , subq_2.listing__ds__month AS listing__ds__month - , subq_2.listing__ds__quarter AS listing__ds__quarter - , subq_2.listing__ds__year AS listing__ds__year - , subq_2.listing__ds__extract_year AS listing__ds__extract_year - , subq_2.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_2.listing__ds__extract_month AS listing__ds__extract_month - , subq_2.listing__ds__extract_day AS listing__ds__extract_day - , subq_2.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_2.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_2.listing__created_at__day AS listing__created_at__day - , subq_2.listing__created_at__week AS listing__created_at__week - , subq_2.listing__created_at__month AS listing__created_at__month - , subq_2.listing__created_at__quarter AS listing__created_at__quarter - , subq_2.listing__created_at__year AS listing__created_at__year - , subq_2.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_2.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_2.listing AS listing - , subq_2.user AS user - , subq_2.listing__user AS listing__user - , subq_2.country_latest AS country_latest - , subq_2.is_lux_latest AS is_lux_latest - , subq_2.capacity_latest AS capacity_latest - , subq_2.listing__country_latest AS listing__country_latest - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_5.home_state_latest AS user__home_state_latest - , subq_2.listings AS listings - , subq_2.largest_listing AS largest_listing - , subq_2.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_2.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -182,78 +182,48 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_1.user + , subq_1.home_state_latest FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.ds_latest__day - , subq_3.ds_latest__week - , subq_3.ds_latest__month - , subq_3.ds_latest__quarter - , subq_3.ds_latest__year - , subq_3.ds_latest__extract_year - , subq_3.ds_latest__extract_quarter - , subq_3.ds_latest__extract_month - , subq_3.ds_latest__extract_day - , subq_3.ds_latest__extract_dow - , subq_3.ds_latest__extract_doy - , subq_3.user__ds_latest__day - , subq_3.user__ds_latest__week - , subq_3.user__ds_latest__month - , subq_3.user__ds_latest__quarter - , subq_3.user__ds_latest__year - , subq_3.user__ds_latest__extract_year - , subq_3.user__ds_latest__extract_quarter - , subq_3.user__ds_latest__extract_month - , subq_3.user__ds_latest__extract_day - , subq_3.user__ds_latest__extract_dow - , subq_3.user__ds_latest__extract_doy - , subq_3.user - , subq_3.home_state_latest - , subq_3.user__home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28000.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - WHERE user__home_state_latest = 'us' - ) subq_4 - ) subq_5 + DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28000.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy + , users_latest_src_28000.home_state_latest + , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , users_latest_src_28000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_28000 + ) subq_1 + ) subq_2 ON - subq_2.user = subq_5.user - ) subq_6 + subq_0.user = subq_2.user + ) subq_3 WHERE user__home_state_latest = 'us' -) subq_7 +) subq_4 GROUP BY - subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_4.listing__is_lux_latest + , subq_4.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index c77b46c217..e54eaffeb6 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Databricks/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -7,27 +7,13 @@ FROM ( -- Join Standard Outputs SELECT listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_11.home_state_latest AS user__home_state_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest FROM ***************************.dim_listings_latest listings_latest_src_28000 - FULL OUTER JOIN ( - -- Constrain Output with WHERE - -- Pass Only Elements: ['home_state_latest', 'user'] - SELECT - subq_9.user - , home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - home_state_latest - , home_state_latest AS user__home_state_latest - , user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_9 - WHERE user__home_state_latest = 'us' - ) subq_11 + FULL OUTER JOIN + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28000.user_id = subq_11.user -) subq_12 + listings_latest_src_28000.user_id = users_latest_src_28000.user_id +) subq_8 WHERE user__home_state_latest = 'us' GROUP BY listing__is_lux_latest diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0.sql index 77721d6e67..d736ad0d03 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -1,127 +1,127 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_4.listing__is_lux_latest + , subq_4.user__home_state_latest FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.created_at__day + , subq_3.created_at__week + , subq_3.created_at__month + , subq_3.created_at__quarter + , subq_3.created_at__year + , subq_3.created_at__extract_year + , subq_3.created_at__extract_quarter + , subq_3.created_at__extract_month + , subq_3.created_at__extract_day + , subq_3.created_at__extract_dow + , subq_3.created_at__extract_doy + , subq_3.listing__ds__day + , subq_3.listing__ds__week + , subq_3.listing__ds__month + , subq_3.listing__ds__quarter + , subq_3.listing__ds__year + , subq_3.listing__ds__extract_year + , subq_3.listing__ds__extract_quarter + , subq_3.listing__ds__extract_month + , subq_3.listing__ds__extract_day + , subq_3.listing__ds__extract_dow + , subq_3.listing__ds__extract_doy + , subq_3.listing__created_at__day + , subq_3.listing__created_at__week + , subq_3.listing__created_at__month + , subq_3.listing__created_at__quarter + , subq_3.listing__created_at__year + , subq_3.listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month + , subq_3.listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy + , subq_3.listing + , subq_3.user + , subq_3.listing__user + , subq_3.country_latest + , subq_3.is_lux_latest + , subq_3.capacity_latest + , subq_3.listing__country_latest + , subq_3.listing__is_lux_latest + , subq_3.listing__capacity_latest + , subq_3.user__home_state_latest + , subq_3.listings + , subq_3.largest_listing + , subq_3.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.created_at__day AS created_at__day - , subq_2.created_at__week AS created_at__week - , subq_2.created_at__month AS created_at__month - , subq_2.created_at__quarter AS created_at__quarter - , subq_2.created_at__year AS created_at__year - , subq_2.created_at__extract_year AS created_at__extract_year - , subq_2.created_at__extract_quarter AS created_at__extract_quarter - , subq_2.created_at__extract_month AS created_at__extract_month - , subq_2.created_at__extract_day AS created_at__extract_day - , subq_2.created_at__extract_dow AS created_at__extract_dow - , subq_2.created_at__extract_doy AS created_at__extract_doy - , subq_2.listing__ds__day AS listing__ds__day - , subq_2.listing__ds__week AS listing__ds__week - , subq_2.listing__ds__month AS listing__ds__month - , subq_2.listing__ds__quarter AS listing__ds__quarter - , subq_2.listing__ds__year AS listing__ds__year - , subq_2.listing__ds__extract_year AS listing__ds__extract_year - , subq_2.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_2.listing__ds__extract_month AS listing__ds__extract_month - , subq_2.listing__ds__extract_day AS listing__ds__extract_day - , subq_2.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_2.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_2.listing__created_at__day AS listing__created_at__day - , subq_2.listing__created_at__week AS listing__created_at__week - , subq_2.listing__created_at__month AS listing__created_at__month - , subq_2.listing__created_at__quarter AS listing__created_at__quarter - , subq_2.listing__created_at__year AS listing__created_at__year - , subq_2.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_2.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_2.listing AS listing - , subq_2.user AS user - , subq_2.listing__user AS listing__user - , subq_2.country_latest AS country_latest - , subq_2.is_lux_latest AS is_lux_latest - , subq_2.capacity_latest AS capacity_latest - , subq_2.listing__country_latest AS listing__country_latest - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_5.home_state_latest AS user__home_state_latest - , subq_2.listings AS listings - , subq_2.largest_listing AS largest_listing - , subq_2.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_2.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -182,78 +182,48 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_1.user + , subq_1.home_state_latest FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.ds_latest__day - , subq_3.ds_latest__week - , subq_3.ds_latest__month - , subq_3.ds_latest__quarter - , subq_3.ds_latest__year - , subq_3.ds_latest__extract_year - , subq_3.ds_latest__extract_quarter - , subq_3.ds_latest__extract_month - , subq_3.ds_latest__extract_day - , subq_3.ds_latest__extract_dow - , subq_3.ds_latest__extract_doy - , subq_3.user__ds_latest__day - , subq_3.user__ds_latest__week - , subq_3.user__ds_latest__month - , subq_3.user__ds_latest__quarter - , subq_3.user__ds_latest__year - , subq_3.user__ds_latest__extract_year - , subq_3.user__ds_latest__extract_quarter - , subq_3.user__ds_latest__extract_month - , subq_3.user__ds_latest__extract_day - , subq_3.user__ds_latest__extract_dow - , subq_3.user__ds_latest__extract_doy - , subq_3.user - , subq_3.home_state_latest - , subq_3.user__home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28000.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - WHERE user__home_state_latest = 'us' - ) subq_4 - ) subq_5 + DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_28000.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy + , users_latest_src_28000.home_state_latest + , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , users_latest_src_28000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_28000 + ) subq_1 + ) subq_2 ON - subq_2.user = subq_5.user - ) subq_6 + subq_0.user = subq_2.user + ) subq_3 WHERE user__home_state_latest = 'us' -) subq_7 +) subq_4 GROUP BY - subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_4.listing__is_lux_latest + , subq_4.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index c77b46c217..e54eaffeb6 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Postgres/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -7,27 +7,13 @@ FROM ( -- Join Standard Outputs SELECT listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_11.home_state_latest AS user__home_state_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest FROM ***************************.dim_listings_latest listings_latest_src_28000 - FULL OUTER JOIN ( - -- Constrain Output with WHERE - -- Pass Only Elements: ['home_state_latest', 'user'] - SELECT - subq_9.user - , home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - home_state_latest - , home_state_latest AS user__home_state_latest - , user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_9 - WHERE user__home_state_latest = 'us' - ) subq_11 + FULL OUTER JOIN + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28000.user_id = subq_11.user -) subq_12 + listings_latest_src_28000.user_id = users_latest_src_28000.user_id +) subq_8 WHERE user__home_state_latest = 'us' GROUP BY listing__is_lux_latest diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0.sql index 78cd0f7b4d..2444ef1956 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -1,127 +1,127 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_4.listing__is_lux_latest + , subq_4.user__home_state_latest FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.created_at__day + , subq_3.created_at__week + , subq_3.created_at__month + , subq_3.created_at__quarter + , subq_3.created_at__year + , subq_3.created_at__extract_year + , subq_3.created_at__extract_quarter + , subq_3.created_at__extract_month + , subq_3.created_at__extract_day + , subq_3.created_at__extract_dow + , subq_3.created_at__extract_doy + , subq_3.listing__ds__day + , subq_3.listing__ds__week + , subq_3.listing__ds__month + , subq_3.listing__ds__quarter + , subq_3.listing__ds__year + , subq_3.listing__ds__extract_year + , subq_3.listing__ds__extract_quarter + , subq_3.listing__ds__extract_month + , subq_3.listing__ds__extract_day + , subq_3.listing__ds__extract_dow + , subq_3.listing__ds__extract_doy + , subq_3.listing__created_at__day + , subq_3.listing__created_at__week + , subq_3.listing__created_at__month + , subq_3.listing__created_at__quarter + , subq_3.listing__created_at__year + , subq_3.listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month + , subq_3.listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy + , subq_3.listing + , subq_3.user + , subq_3.listing__user + , subq_3.country_latest + , subq_3.is_lux_latest + , subq_3.capacity_latest + , subq_3.listing__country_latest + , subq_3.listing__is_lux_latest + , subq_3.listing__capacity_latest + , subq_3.user__home_state_latest + , subq_3.listings + , subq_3.largest_listing + , subq_3.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.created_at__day AS created_at__day - , subq_2.created_at__week AS created_at__week - , subq_2.created_at__month AS created_at__month - , subq_2.created_at__quarter AS created_at__quarter - , subq_2.created_at__year AS created_at__year - , subq_2.created_at__extract_year AS created_at__extract_year - , subq_2.created_at__extract_quarter AS created_at__extract_quarter - , subq_2.created_at__extract_month AS created_at__extract_month - , subq_2.created_at__extract_day AS created_at__extract_day - , subq_2.created_at__extract_dow AS created_at__extract_dow - , subq_2.created_at__extract_doy AS created_at__extract_doy - , subq_2.listing__ds__day AS listing__ds__day - , subq_2.listing__ds__week AS listing__ds__week - , subq_2.listing__ds__month AS listing__ds__month - , subq_2.listing__ds__quarter AS listing__ds__quarter - , subq_2.listing__ds__year AS listing__ds__year - , subq_2.listing__ds__extract_year AS listing__ds__extract_year - , subq_2.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_2.listing__ds__extract_month AS listing__ds__extract_month - , subq_2.listing__ds__extract_day AS listing__ds__extract_day - , subq_2.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_2.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_2.listing__created_at__day AS listing__created_at__day - , subq_2.listing__created_at__week AS listing__created_at__week - , subq_2.listing__created_at__month AS listing__created_at__month - , subq_2.listing__created_at__quarter AS listing__created_at__quarter - , subq_2.listing__created_at__year AS listing__created_at__year - , subq_2.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_2.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_2.listing AS listing - , subq_2.user AS user - , subq_2.listing__user AS listing__user - , subq_2.country_latest AS country_latest - , subq_2.is_lux_latest AS is_lux_latest - , subq_2.capacity_latest AS capacity_latest - , subq_2.listing__country_latest AS listing__country_latest - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_5.home_state_latest AS user__home_state_latest - , subq_2.listings AS listings - , subq_2.largest_listing AS largest_listing - , subq_2.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_2.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -182,78 +182,48 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_1.user + , subq_1.home_state_latest FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.ds_latest__day - , subq_3.ds_latest__week - , subq_3.ds_latest__month - , subq_3.ds_latest__quarter - , subq_3.ds_latest__year - , subq_3.ds_latest__extract_year - , subq_3.ds_latest__extract_quarter - , subq_3.ds_latest__extract_month - , subq_3.ds_latest__extract_day - , subq_3.ds_latest__extract_dow - , subq_3.ds_latest__extract_doy - , subq_3.user__ds_latest__day - , subq_3.user__ds_latest__week - , subq_3.user__ds_latest__month - , subq_3.user__ds_latest__quarter - , subq_3.user__ds_latest__year - , subq_3.user__ds_latest__extract_year - , subq_3.user__ds_latest__extract_quarter - , subq_3.user__ds_latest__extract_month - , subq_3.user__ds_latest__extract_day - , subq_3.user__ds_latest__extract_dow - , subq_3.user__ds_latest__extract_doy - , subq_3.user - , subq_3.home_state_latest - , subq_3.user__home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28000.ds) END AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28000.ds) END AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - WHERE user__home_state_latest = 'us' - ) subq_4 - ) subq_5 + DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28000.ds) END AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy + , users_latest_src_28000.home_state_latest + , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28000.ds) END AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , users_latest_src_28000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_28000 + ) subq_1 + ) subq_2 ON - subq_2.user = subq_5.user - ) subq_6 + subq_0.user = subq_2.user + ) subq_3 WHERE user__home_state_latest = 'us' -) subq_7 +) subq_4 GROUP BY - subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_4.listing__is_lux_latest + , subq_4.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index c77b46c217..e54eaffeb6 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Redshift/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -7,27 +7,13 @@ FROM ( -- Join Standard Outputs SELECT listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_11.home_state_latest AS user__home_state_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest FROM ***************************.dim_listings_latest listings_latest_src_28000 - FULL OUTER JOIN ( - -- Constrain Output with WHERE - -- Pass Only Elements: ['home_state_latest', 'user'] - SELECT - subq_9.user - , home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - home_state_latest - , home_state_latest AS user__home_state_latest - , user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_9 - WHERE user__home_state_latest = 'us' - ) subq_11 + FULL OUTER JOIN + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28000.user_id = subq_11.user -) subq_12 + listings_latest_src_28000.user_id = users_latest_src_28000.user_id +) subq_8 WHERE user__home_state_latest = 'us' GROUP BY listing__is_lux_latest diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0.sql index 4d8a81ae07..fe092394e6 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -1,127 +1,127 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_4.listing__is_lux_latest + , subq_4.user__home_state_latest FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.created_at__day + , subq_3.created_at__week + , subq_3.created_at__month + , subq_3.created_at__quarter + , subq_3.created_at__year + , subq_3.created_at__extract_year + , subq_3.created_at__extract_quarter + , subq_3.created_at__extract_month + , subq_3.created_at__extract_day + , subq_3.created_at__extract_dow + , subq_3.created_at__extract_doy + , subq_3.listing__ds__day + , subq_3.listing__ds__week + , subq_3.listing__ds__month + , subq_3.listing__ds__quarter + , subq_3.listing__ds__year + , subq_3.listing__ds__extract_year + , subq_3.listing__ds__extract_quarter + , subq_3.listing__ds__extract_month + , subq_3.listing__ds__extract_day + , subq_3.listing__ds__extract_dow + , subq_3.listing__ds__extract_doy + , subq_3.listing__created_at__day + , subq_3.listing__created_at__week + , subq_3.listing__created_at__month + , subq_3.listing__created_at__quarter + , subq_3.listing__created_at__year + , subq_3.listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month + , subq_3.listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy + , subq_3.listing + , subq_3.user + , subq_3.listing__user + , subq_3.country_latest + , subq_3.is_lux_latest + , subq_3.capacity_latest + , subq_3.listing__country_latest + , subq_3.listing__is_lux_latest + , subq_3.listing__capacity_latest + , subq_3.user__home_state_latest + , subq_3.listings + , subq_3.largest_listing + , subq_3.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.created_at__day AS created_at__day - , subq_2.created_at__week AS created_at__week - , subq_2.created_at__month AS created_at__month - , subq_2.created_at__quarter AS created_at__quarter - , subq_2.created_at__year AS created_at__year - , subq_2.created_at__extract_year AS created_at__extract_year - , subq_2.created_at__extract_quarter AS created_at__extract_quarter - , subq_2.created_at__extract_month AS created_at__extract_month - , subq_2.created_at__extract_day AS created_at__extract_day - , subq_2.created_at__extract_dow AS created_at__extract_dow - , subq_2.created_at__extract_doy AS created_at__extract_doy - , subq_2.listing__ds__day AS listing__ds__day - , subq_2.listing__ds__week AS listing__ds__week - , subq_2.listing__ds__month AS listing__ds__month - , subq_2.listing__ds__quarter AS listing__ds__quarter - , subq_2.listing__ds__year AS listing__ds__year - , subq_2.listing__ds__extract_year AS listing__ds__extract_year - , subq_2.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_2.listing__ds__extract_month AS listing__ds__extract_month - , subq_2.listing__ds__extract_day AS listing__ds__extract_day - , subq_2.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_2.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_2.listing__created_at__day AS listing__created_at__day - , subq_2.listing__created_at__week AS listing__created_at__week - , subq_2.listing__created_at__month AS listing__created_at__month - , subq_2.listing__created_at__quarter AS listing__created_at__quarter - , subq_2.listing__created_at__year AS listing__created_at__year - , subq_2.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_2.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_2.listing AS listing - , subq_2.user AS user - , subq_2.listing__user AS listing__user - , subq_2.country_latest AS country_latest - , subq_2.is_lux_latest AS is_lux_latest - , subq_2.capacity_latest AS capacity_latest - , subq_2.listing__country_latest AS listing__country_latest - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_5.home_state_latest AS user__home_state_latest - , subq_2.listings AS listings - , subq_2.largest_listing AS largest_listing - , subq_2.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_2.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -182,78 +182,48 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_1.user + , subq_1.home_state_latest FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.ds_latest__day - , subq_3.ds_latest__week - , subq_3.ds_latest__month - , subq_3.ds_latest__quarter - , subq_3.ds_latest__year - , subq_3.ds_latest__extract_year - , subq_3.ds_latest__extract_quarter - , subq_3.ds_latest__extract_month - , subq_3.ds_latest__extract_day - , subq_3.ds_latest__extract_dow - , subq_3.ds_latest__extract_doy - , subq_3.user__ds_latest__day - , subq_3.user__ds_latest__week - , subq_3.user__ds_latest__month - , subq_3.user__ds_latest__quarter - , subq_3.user__ds_latest__year - , subq_3.user__ds_latest__extract_year - , subq_3.user__ds_latest__extract_quarter - , subq_3.user__ds_latest__extract_month - , subq_3.user__ds_latest__extract_day - , subq_3.user__ds_latest__extract_dow - , subq_3.user__ds_latest__extract_doy - , subq_3.user - , subq_3.home_state_latest - , subq_3.user__home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28000.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - WHERE user__home_state_latest = 'us' - ) subq_4 - ) subq_5 + DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_28000.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy + , users_latest_src_28000.home_state_latest + , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , users_latest_src_28000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_28000 + ) subq_1 + ) subq_2 ON - subq_2.user = subq_5.user - ) subq_6 + subq_0.user = subq_2.user + ) subq_3 WHERE user__home_state_latest = 'us' -) subq_7 +) subq_4 GROUP BY - subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_4.listing__is_lux_latest + , subq_4.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index c77b46c217..e54eaffeb6 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Snowflake/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -7,27 +7,13 @@ FROM ( -- Join Standard Outputs SELECT listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_11.home_state_latest AS user__home_state_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest FROM ***************************.dim_listings_latest listings_latest_src_28000 - FULL OUTER JOIN ( - -- Constrain Output with WHERE - -- Pass Only Elements: ['home_state_latest', 'user'] - SELECT - subq_9.user - , home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - home_state_latest - , home_state_latest AS user__home_state_latest - , user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_9 - WHERE user__home_state_latest = 'us' - ) subq_11 + FULL OUTER JOIN + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28000.user_id = subq_11.user -) subq_12 + listings_latest_src_28000.user_id = users_latest_src_28000.user_id +) subq_8 WHERE user__home_state_latest = 'us' GROUP BY listing__is_lux_latest diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimension_values_with_a_join_and_a_filter__plan0.sql b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimension_values_with_a_join_and_a_filter__plan0.sql index 4f779da15b..478b5d81be 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimension_values_with_a_join_and_a_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimension_values_with_a_join_and_a_filter__plan0.sql @@ -1,127 +1,127 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest'] SELECT - subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_4.listing__is_lux_latest + , subq_4.user__home_state_latest FROM ( -- Constrain Output with WHERE SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.created_at__day - , subq_6.created_at__week - , subq_6.created_at__month - , subq_6.created_at__quarter - , subq_6.created_at__year - , subq_6.created_at__extract_year - , subq_6.created_at__extract_quarter - , subq_6.created_at__extract_month - , subq_6.created_at__extract_day - , subq_6.created_at__extract_dow - , subq_6.created_at__extract_doy - , subq_6.listing__ds__day - , subq_6.listing__ds__week - , subq_6.listing__ds__month - , subq_6.listing__ds__quarter - , subq_6.listing__ds__year - , subq_6.listing__ds__extract_year - , subq_6.listing__ds__extract_quarter - , subq_6.listing__ds__extract_month - , subq_6.listing__ds__extract_day - , subq_6.listing__ds__extract_dow - , subq_6.listing__ds__extract_doy - , subq_6.listing__created_at__day - , subq_6.listing__created_at__week - , subq_6.listing__created_at__month - , subq_6.listing__created_at__quarter - , subq_6.listing__created_at__year - , subq_6.listing__created_at__extract_year - , subq_6.listing__created_at__extract_quarter - , subq_6.listing__created_at__extract_month - , subq_6.listing__created_at__extract_day - , subq_6.listing__created_at__extract_dow - , subq_6.listing__created_at__extract_doy - , subq_6.listing - , subq_6.user - , subq_6.listing__user - , subq_6.country_latest - , subq_6.is_lux_latest - , subq_6.capacity_latest - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings - , subq_6.largest_listing - , subq_6.smallest_listing + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.created_at__day + , subq_3.created_at__week + , subq_3.created_at__month + , subq_3.created_at__quarter + , subq_3.created_at__year + , subq_3.created_at__extract_year + , subq_3.created_at__extract_quarter + , subq_3.created_at__extract_month + , subq_3.created_at__extract_day + , subq_3.created_at__extract_dow + , subq_3.created_at__extract_doy + , subq_3.listing__ds__day + , subq_3.listing__ds__week + , subq_3.listing__ds__month + , subq_3.listing__ds__quarter + , subq_3.listing__ds__year + , subq_3.listing__ds__extract_year + , subq_3.listing__ds__extract_quarter + , subq_3.listing__ds__extract_month + , subq_3.listing__ds__extract_day + , subq_3.listing__ds__extract_dow + , subq_3.listing__ds__extract_doy + , subq_3.listing__created_at__day + , subq_3.listing__created_at__week + , subq_3.listing__created_at__month + , subq_3.listing__created_at__quarter + , subq_3.listing__created_at__year + , subq_3.listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month + , subq_3.listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy + , subq_3.listing + , subq_3.user + , subq_3.listing__user + , subq_3.country_latest + , subq_3.is_lux_latest + , subq_3.capacity_latest + , subq_3.listing__country_latest + , subq_3.listing__is_lux_latest + , subq_3.listing__capacity_latest + , subq_3.user__home_state_latest + , subq_3.listings + , subq_3.largest_listing + , subq_3.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.created_at__day AS created_at__day - , subq_2.created_at__week AS created_at__week - , subq_2.created_at__month AS created_at__month - , subq_2.created_at__quarter AS created_at__quarter - , subq_2.created_at__year AS created_at__year - , subq_2.created_at__extract_year AS created_at__extract_year - , subq_2.created_at__extract_quarter AS created_at__extract_quarter - , subq_2.created_at__extract_month AS created_at__extract_month - , subq_2.created_at__extract_day AS created_at__extract_day - , subq_2.created_at__extract_dow AS created_at__extract_dow - , subq_2.created_at__extract_doy AS created_at__extract_doy - , subq_2.listing__ds__day AS listing__ds__day - , subq_2.listing__ds__week AS listing__ds__week - , subq_2.listing__ds__month AS listing__ds__month - , subq_2.listing__ds__quarter AS listing__ds__quarter - , subq_2.listing__ds__year AS listing__ds__year - , subq_2.listing__ds__extract_year AS listing__ds__extract_year - , subq_2.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_2.listing__ds__extract_month AS listing__ds__extract_month - , subq_2.listing__ds__extract_day AS listing__ds__extract_day - , subq_2.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_2.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_2.listing__created_at__day AS listing__created_at__day - , subq_2.listing__created_at__week AS listing__created_at__week - , subq_2.listing__created_at__month AS listing__created_at__month - , subq_2.listing__created_at__quarter AS listing__created_at__quarter - , subq_2.listing__created_at__year AS listing__created_at__year - , subq_2.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_2.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_2.listing AS listing - , subq_2.user AS user - , subq_2.listing__user AS listing__user - , subq_2.country_latest AS country_latest - , subq_2.is_lux_latest AS is_lux_latest - , subq_2.capacity_latest AS capacity_latest - , subq_2.listing__country_latest AS listing__country_latest - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_5.home_state_latest AS user__home_state_latest - , subq_2.listings AS listings - , subq_2.largest_listing AS largest_listing - , subq_2.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_2.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -182,78 +182,48 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 + ) subq_0 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_4.user - , subq_4.home_state_latest + subq_1.user + , subq_1.home_state_latest FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.ds_latest__day - , subq_3.ds_latest__week - , subq_3.ds_latest__month - , subq_3.ds_latest__quarter - , subq_3.ds_latest__year - , subq_3.ds_latest__extract_year - , subq_3.ds_latest__extract_quarter - , subq_3.ds_latest__extract_month - , subq_3.ds_latest__extract_day - , subq_3.ds_latest__extract_dow - , subq_3.ds_latest__extract_doy - , subq_3.user__ds_latest__day - , subq_3.user__ds_latest__week - , subq_3.user__ds_latest__month - , subq_3.user__ds_latest__quarter - , subq_3.user__ds_latest__year - , subq_3.user__ds_latest__extract_year - , subq_3.user__ds_latest__extract_quarter - , subq_3.user__ds_latest__extract_month - , subq_3.user__ds_latest__extract_day - , subq_3.user__ds_latest__extract_dow - , subq_3.user__ds_latest__extract_doy - , subq_3.user - , subq_3.home_state_latest - , subq_3.user__home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28000.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - WHERE user__home_state_latest = 'us' - ) subq_4 - ) subq_5 + DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28000.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy + , users_latest_src_28000.home_state_latest + , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , users_latest_src_28000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_28000 + ) subq_1 + ) subq_2 ON - subq_2.user = subq_5.user - ) subq_6 + subq_0.user = subq_2.user + ) subq_3 WHERE user__home_state_latest = 'us' -) subq_7 +) subq_4 GROUP BY - subq_7.listing__is_lux_latest - , subq_7.user__home_state_latest + subq_4.listing__is_lux_latest + , subq_4.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql index c77b46c217..e54eaffeb6 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/Trino/test_dimension_values_with_a_join_and_a_filter__plan0_optimized.sql @@ -7,27 +7,13 @@ FROM ( -- Join Standard Outputs SELECT listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_11.home_state_latest AS user__home_state_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest FROM ***************************.dim_listings_latest listings_latest_src_28000 - FULL OUTER JOIN ( - -- Constrain Output with WHERE - -- Pass Only Elements: ['home_state_latest', 'user'] - SELECT - subq_9.user - , home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - home_state_latest - , home_state_latest AS user__home_state_latest - , user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_9 - WHERE user__home_state_latest = 'us' - ) subq_11 + FULL OUTER JOIN + ***************************.dim_users_latest users_latest_src_28000 ON - listings_latest_src_28000.user_id = subq_11.user -) subq_12 + listings_latest_src_28000.user_id = users_latest_src_28000.user_id +) subq_8 WHERE user__home_state_latest = 'us' GROUP BY listing__is_lux_latest diff --git a/tests_metricflow/snapshots/test_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 eb8439edeb..6f8d7cd5c4 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_27.third_hop_count + subq_25.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_26.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_24.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_25.third_hop_count + subq_23.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_24.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_24.third_hop_count + subq_22.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_22.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_23.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_23.third_hop_count + subq_21.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_21.third_hop_count FROM ( -- Join Standard Outputs SELECT - subq_13.customer_third_hop_id AS customer_third_hop_id - , subq_22.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id - , subq_22.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_13.third_hop_count AS third_hop_count + subq_11.customer_third_hop_id AS customer_third_hop_id + , subq_20.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_20.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_11.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_12.customer_third_hop_id - , subq_12.third_hop_count + subq_10.customer_third_hop_id + , subq_10.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - subq_11.third_hop_ds__day - , subq_11.third_hop_ds__week - , subq_11.third_hop_ds__month - , subq_11.third_hop_ds__quarter - , subq_11.third_hop_ds__year - , subq_11.third_hop_ds__extract_year - , subq_11.third_hop_ds__extract_quarter - , subq_11.third_hop_ds__extract_month - , subq_11.third_hop_ds__extract_day - , subq_11.third_hop_ds__extract_dow - , subq_11.third_hop_ds__extract_doy - , subq_11.customer_third_hop_id__third_hop_ds__day - , subq_11.customer_third_hop_id__third_hop_ds__week - , subq_11.customer_third_hop_id__third_hop_ds__month - , subq_11.customer_third_hop_id__third_hop_ds__quarter - , subq_11.customer_third_hop_id__third_hop_ds__year - , subq_11.customer_third_hop_id__third_hop_ds__extract_year - , subq_11.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_11.customer_third_hop_id__third_hop_ds__extract_month - , subq_11.customer_third_hop_id__third_hop_ds__extract_day - , subq_11.customer_third_hop_id__third_hop_ds__extract_dow - , subq_11.customer_third_hop_id__third_hop_ds__extract_doy - , subq_11.third_hop_ds__day AS metric_time__day - , subq_11.third_hop_ds__week AS metric_time__week - , subq_11.third_hop_ds__month AS metric_time__month - , subq_11.third_hop_ds__quarter AS metric_time__quarter - , subq_11.third_hop_ds__year AS metric_time__year - , subq_11.third_hop_ds__extract_year AS metric_time__extract_year - , subq_11.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_11.third_hop_ds__extract_month AS metric_time__extract_month - , subq_11.third_hop_ds__extract_day AS metric_time__extract_day - , subq_11.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_11.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_11.customer_third_hop_id - , subq_11.value - , subq_11.customer_third_hop_id__value - , subq_11.third_hop_count + subq_9.third_hop_ds__day + , subq_9.third_hop_ds__week + , subq_9.third_hop_ds__month + , subq_9.third_hop_ds__quarter + , subq_9.third_hop_ds__year + , subq_9.third_hop_ds__extract_year + , subq_9.third_hop_ds__extract_quarter + , subq_9.third_hop_ds__extract_month + , subq_9.third_hop_ds__extract_day + , subq_9.third_hop_ds__extract_dow + , subq_9.third_hop_ds__extract_doy + , subq_9.customer_third_hop_id__third_hop_ds__day + , subq_9.customer_third_hop_id__third_hop_ds__week + , subq_9.customer_third_hop_id__third_hop_ds__month + , subq_9.customer_third_hop_id__third_hop_ds__quarter + , subq_9.customer_third_hop_id__third_hop_ds__year + , subq_9.customer_third_hop_id__third_hop_ds__extract_year + , subq_9.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_9.customer_third_hop_id__third_hop_ds__extract_month + , subq_9.customer_third_hop_id__third_hop_ds__extract_day + , subq_9.customer_third_hop_id__third_hop_ds__extract_dow + , subq_9.customer_third_hop_id__third_hop_ds__extract_doy + , subq_9.third_hop_ds__day AS metric_time__day + , subq_9.third_hop_ds__week AS metric_time__week + , subq_9.third_hop_ds__month AS metric_time__month + , subq_9.third_hop_ds__quarter AS metric_time__quarter + , subq_9.third_hop_ds__year AS metric_time__year + , subq_9.third_hop_ds__extract_year AS metric_time__extract_year + , subq_9.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_9.third_hop_ds__extract_month AS metric_time__extract_month + , subq_9.third_hop_ds__extract_day AS metric_time__extract_day + , subq_9.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_9.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_9.customer_third_hop_id + , subq_9.value + , subq_9.customer_third_hop_id__value + , subq_9.third_hop_count FROM ( -- Read Elements From Semantic Model 'third_hop_table' SELECT @@ -101,151 +101,151 @@ FROM ( , EXTRACT(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_11 - ) subq_12 - ) subq_13 + ) subq_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_21.customer_id__customer_third_hop_id - , subq_21.customer_id__customer_third_hop_id__paraguayan_customers + subq_19.customer_id__customer_third_hop_id + , subq_19.customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Compute Metrics via Expressions SELECT - subq_20.customer_id__customer_third_hop_id - , subq_20.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_18.customer_id__customer_third_hop_id + , subq_18.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Aggregate Measures SELECT - subq_19.customer_id__customer_third_hop_id - , SUM(subq_19.customers_with_other_data) AS customers_with_other_data + subq_17.customer_id__customer_third_hop_id + , SUM(subq_17.customers_with_other_data) AS customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] SELECT - subq_18.customer_id__customer_third_hop_id - , subq_18.customers_with_other_data + subq_16.customer_id__customer_third_hop_id + , subq_16.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_17.customer_id__customer_third_hop_id - , subq_17.customer_id__country - , subq_17.customers_with_other_data + subq_15.customer_id__customer_third_hop_id + , subq_15.customer_id__country + , subq_15.customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT - subq_16.customer_id__customer_third_hop_id - , subq_16.customer_id__country - , subq_16.customers_with_other_data + subq_14.customer_id__customer_third_hop_id + , subq_14.customer_id__country + , subq_14.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_15.acquired_ds__day - , subq_15.acquired_ds__week - , subq_15.acquired_ds__month - , subq_15.acquired_ds__quarter - , subq_15.acquired_ds__year - , subq_15.acquired_ds__extract_year - , subq_15.acquired_ds__extract_quarter - , subq_15.acquired_ds__extract_month - , subq_15.acquired_ds__extract_day - , subq_15.acquired_ds__extract_dow - , subq_15.acquired_ds__extract_doy - , subq_15.customer_id__acquired_ds__day - , subq_15.customer_id__acquired_ds__week - , subq_15.customer_id__acquired_ds__month - , subq_15.customer_id__acquired_ds__quarter - , subq_15.customer_id__acquired_ds__year - , subq_15.customer_id__acquired_ds__extract_year - , subq_15.customer_id__acquired_ds__extract_quarter - , subq_15.customer_id__acquired_ds__extract_month - , subq_15.customer_id__acquired_ds__extract_day - , subq_15.customer_id__acquired_ds__extract_dow - , subq_15.customer_id__acquired_ds__extract_doy - , subq_15.customer_third_hop_id__acquired_ds__day - , subq_15.customer_third_hop_id__acquired_ds__week - , subq_15.customer_third_hop_id__acquired_ds__month - , subq_15.customer_third_hop_id__acquired_ds__quarter - , subq_15.customer_third_hop_id__acquired_ds__year - , subq_15.customer_third_hop_id__acquired_ds__extract_year - , subq_15.customer_third_hop_id__acquired_ds__extract_quarter - , subq_15.customer_third_hop_id__acquired_ds__extract_month - , subq_15.customer_third_hop_id__acquired_ds__extract_day - , subq_15.customer_third_hop_id__acquired_ds__extract_dow - , subq_15.customer_third_hop_id__acquired_ds__extract_doy - , subq_15.metric_time__day - , subq_15.metric_time__week - , subq_15.metric_time__month - , subq_15.metric_time__quarter - , subq_15.metric_time__year - , subq_15.metric_time__extract_year - , subq_15.metric_time__extract_quarter - , subq_15.metric_time__extract_month - , subq_15.metric_time__extract_day - , subq_15.metric_time__extract_dow - , subq_15.metric_time__extract_doy - , subq_15.customer_id - , subq_15.customer_third_hop_id - , subq_15.customer_id__customer_third_hop_id - , subq_15.customer_third_hop_id__customer_id - , subq_15.country - , subq_15.customer_id__country - , subq_15.customer_third_hop_id__country - , subq_15.customers_with_other_data + subq_13.acquired_ds__day + , subq_13.acquired_ds__week + , subq_13.acquired_ds__month + , subq_13.acquired_ds__quarter + , subq_13.acquired_ds__year + , subq_13.acquired_ds__extract_year + , subq_13.acquired_ds__extract_quarter + , subq_13.acquired_ds__extract_month + , subq_13.acquired_ds__extract_day + , subq_13.acquired_ds__extract_dow + , subq_13.acquired_ds__extract_doy + , subq_13.customer_id__acquired_ds__day + , subq_13.customer_id__acquired_ds__week + , subq_13.customer_id__acquired_ds__month + , subq_13.customer_id__acquired_ds__quarter + , subq_13.customer_id__acquired_ds__year + , subq_13.customer_id__acquired_ds__extract_year + , subq_13.customer_id__acquired_ds__extract_quarter + , subq_13.customer_id__acquired_ds__extract_month + , subq_13.customer_id__acquired_ds__extract_day + , subq_13.customer_id__acquired_ds__extract_dow + , subq_13.customer_id__acquired_ds__extract_doy + , subq_13.customer_third_hop_id__acquired_ds__day + , subq_13.customer_third_hop_id__acquired_ds__week + , subq_13.customer_third_hop_id__acquired_ds__month + , subq_13.customer_third_hop_id__acquired_ds__quarter + , subq_13.customer_third_hop_id__acquired_ds__year + , subq_13.customer_third_hop_id__acquired_ds__extract_year + , subq_13.customer_third_hop_id__acquired_ds__extract_quarter + , subq_13.customer_third_hop_id__acquired_ds__extract_month + , subq_13.customer_third_hop_id__acquired_ds__extract_day + , subq_13.customer_third_hop_id__acquired_ds__extract_dow + , subq_13.customer_third_hop_id__acquired_ds__extract_doy + , subq_13.metric_time__day + , subq_13.metric_time__week + , subq_13.metric_time__month + , subq_13.metric_time__quarter + , subq_13.metric_time__year + , subq_13.metric_time__extract_year + , subq_13.metric_time__extract_quarter + , subq_13.metric_time__extract_month + , subq_13.metric_time__extract_day + , subq_13.metric_time__extract_dow + , subq_13.metric_time__extract_doy + , subq_13.customer_id + , subq_13.customer_third_hop_id + , subq_13.customer_id__customer_third_hop_id + , subq_13.customer_third_hop_id__customer_id + , subq_13.country + , subq_13.customer_id__country + , subq_13.customer_third_hop_id__country + , subq_13.customers_with_other_data FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - subq_14.acquired_ds__day - , subq_14.acquired_ds__week - , subq_14.acquired_ds__month - , subq_14.acquired_ds__quarter - , subq_14.acquired_ds__year - , subq_14.acquired_ds__extract_year - , subq_14.acquired_ds__extract_quarter - , subq_14.acquired_ds__extract_month - , subq_14.acquired_ds__extract_day - , subq_14.acquired_ds__extract_dow - , subq_14.acquired_ds__extract_doy - , subq_14.customer_id__acquired_ds__day - , subq_14.customer_id__acquired_ds__week - , subq_14.customer_id__acquired_ds__month - , subq_14.customer_id__acquired_ds__quarter - , subq_14.customer_id__acquired_ds__year - , subq_14.customer_id__acquired_ds__extract_year - , subq_14.customer_id__acquired_ds__extract_quarter - , subq_14.customer_id__acquired_ds__extract_month - , subq_14.customer_id__acquired_ds__extract_day - , subq_14.customer_id__acquired_ds__extract_dow - , subq_14.customer_id__acquired_ds__extract_doy - , subq_14.customer_third_hop_id__acquired_ds__day - , subq_14.customer_third_hop_id__acquired_ds__week - , subq_14.customer_third_hop_id__acquired_ds__month - , subq_14.customer_third_hop_id__acquired_ds__quarter - , subq_14.customer_third_hop_id__acquired_ds__year - , subq_14.customer_third_hop_id__acquired_ds__extract_year - , subq_14.customer_third_hop_id__acquired_ds__extract_quarter - , subq_14.customer_third_hop_id__acquired_ds__extract_month - , subq_14.customer_third_hop_id__acquired_ds__extract_day - , subq_14.customer_third_hop_id__acquired_ds__extract_dow - , subq_14.customer_third_hop_id__acquired_ds__extract_doy - , subq_14.acquired_ds__day AS metric_time__day - , subq_14.acquired_ds__week AS metric_time__week - , subq_14.acquired_ds__month AS metric_time__month - , subq_14.acquired_ds__quarter AS metric_time__quarter - , subq_14.acquired_ds__year AS metric_time__year - , subq_14.acquired_ds__extract_year AS metric_time__extract_year - , subq_14.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_14.acquired_ds__extract_month AS metric_time__extract_month - , subq_14.acquired_ds__extract_day AS metric_time__extract_day - , subq_14.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_14.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_14.customer_id - , subq_14.customer_third_hop_id - , subq_14.customer_id__customer_third_hop_id - , subq_14.customer_third_hop_id__customer_id - , subq_14.country - , subq_14.customer_id__country - , subq_14.customer_third_hop_id__country - , subq_14.customers_with_other_data + subq_12.acquired_ds__day + , subq_12.acquired_ds__week + , subq_12.acquired_ds__month + , subq_12.acquired_ds__quarter + , subq_12.acquired_ds__year + , subq_12.acquired_ds__extract_year + , subq_12.acquired_ds__extract_quarter + , subq_12.acquired_ds__extract_month + , subq_12.acquired_ds__extract_day + , subq_12.acquired_ds__extract_dow + , subq_12.acquired_ds__extract_doy + , subq_12.customer_id__acquired_ds__day + , subq_12.customer_id__acquired_ds__week + , subq_12.customer_id__acquired_ds__month + , subq_12.customer_id__acquired_ds__quarter + , subq_12.customer_id__acquired_ds__year + , subq_12.customer_id__acquired_ds__extract_year + , subq_12.customer_id__acquired_ds__extract_quarter + , subq_12.customer_id__acquired_ds__extract_month + , subq_12.customer_id__acquired_ds__extract_day + , subq_12.customer_id__acquired_ds__extract_dow + , subq_12.customer_id__acquired_ds__extract_doy + , subq_12.customer_third_hop_id__acquired_ds__day + , subq_12.customer_third_hop_id__acquired_ds__week + , subq_12.customer_third_hop_id__acquired_ds__month + , subq_12.customer_third_hop_id__acquired_ds__quarter + , subq_12.customer_third_hop_id__acquired_ds__year + , subq_12.customer_third_hop_id__acquired_ds__extract_year + , subq_12.customer_third_hop_id__acquired_ds__extract_quarter + , subq_12.customer_third_hop_id__acquired_ds__extract_month + , subq_12.customer_third_hop_id__acquired_ds__extract_day + , subq_12.customer_third_hop_id__acquired_ds__extract_dow + , subq_12.customer_third_hop_id__acquired_ds__extract_doy + , subq_12.acquired_ds__day AS metric_time__day + , subq_12.acquired_ds__week AS metric_time__week + , subq_12.acquired_ds__month AS metric_time__month + , subq_12.acquired_ds__quarter AS metric_time__quarter + , subq_12.acquired_ds__year AS metric_time__year + , subq_12.acquired_ds__extract_year AS metric_time__extract_year + , subq_12.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_12.acquired_ds__extract_month AS metric_time__extract_month + , subq_12.acquired_ds__extract_day AS metric_time__extract_day + , subq_12.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_12.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_12.customer_id + , subq_12.customer_third_hop_id + , subq_12.customer_id__customer_third_hop_id + , subq_12.customer_third_hop_id__customer_id + , subq_12.country + , subq_12.customer_id__country + , subq_12.customer_third_hop_id__country + , subq_12.customers_with_other_data FROM ( -- Read Elements From Semantic Model 'customer_other_data' SELECT @@ -291,24 +291,24 @@ FROM ( , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_14 - ) subq_15 + ) subq_12 + ) subq_13 WHERE customer_id__country = 'paraguay' - ) subq_16 - ) subq_17 + ) subq_14 + ) subq_15 WHERE customer_id__country = 'paraguay' - ) subq_18 - ) subq_19 + ) subq_16 + ) subq_17 GROUP BY customer_id__customer_third_hop_id - ) subq_20 - ) subq_21 - ) subq_22 + ) subq_18 + ) subq_19 + ) subq_20 ON - subq_13.customer_third_hop_id = subq_22.customer_id__customer_third_hop_id - ) subq_23 - ) subq_24 + subq_11.customer_third_hop_id = subq_20.customer_id__customer_third_hop_id + ) subq_21 + ) subq_22 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_23 + ) subq_24 +) subq_25 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/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 7c12d6cf98..4af49531fb 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_39.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_37.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -35,14 +35,14 @@ FROM ( , country AS customer_id__country , 1 AS customers_with_other_data FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_32 + ) subq_30 WHERE customer_id__country = 'paraguay' - ) subq_34 + ) subq_32 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_39 + ) subq_37 ON - third_hop_table_src_22000.customer_third_hop_id = subq_39.customer_id__customer_third_hop_id -) subq_41 + third_hop_table_src_22000.customer_third_hop_id = subq_37.customer_id__customer_third_hop_id +) subq_39 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_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 add4b98b45..b53d8d1142 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_27.third_hop_count + subq_25.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_26.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_24.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_25.third_hop_count + subq_23.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_24.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_24.third_hop_count + subq_22.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_22.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_23.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_23.third_hop_count + subq_21.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_21.third_hop_count FROM ( -- Join Standard Outputs SELECT - subq_13.customer_third_hop_id AS customer_third_hop_id - , subq_22.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id - , subq_22.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_13.third_hop_count AS third_hop_count + subq_11.customer_third_hop_id AS customer_third_hop_id + , subq_20.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_20.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_11.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_12.customer_third_hop_id - , subq_12.third_hop_count + subq_10.customer_third_hop_id + , subq_10.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - subq_11.third_hop_ds__day - , subq_11.third_hop_ds__week - , subq_11.third_hop_ds__month - , subq_11.third_hop_ds__quarter - , subq_11.third_hop_ds__year - , subq_11.third_hop_ds__extract_year - , subq_11.third_hop_ds__extract_quarter - , subq_11.third_hop_ds__extract_month - , subq_11.third_hop_ds__extract_day - , subq_11.third_hop_ds__extract_dow - , subq_11.third_hop_ds__extract_doy - , subq_11.customer_third_hop_id__third_hop_ds__day - , subq_11.customer_third_hop_id__third_hop_ds__week - , subq_11.customer_third_hop_id__third_hop_ds__month - , subq_11.customer_third_hop_id__third_hop_ds__quarter - , subq_11.customer_third_hop_id__third_hop_ds__year - , subq_11.customer_third_hop_id__third_hop_ds__extract_year - , subq_11.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_11.customer_third_hop_id__third_hop_ds__extract_month - , subq_11.customer_third_hop_id__third_hop_ds__extract_day - , subq_11.customer_third_hop_id__third_hop_ds__extract_dow - , subq_11.customer_third_hop_id__third_hop_ds__extract_doy - , subq_11.third_hop_ds__day AS metric_time__day - , subq_11.third_hop_ds__week AS metric_time__week - , subq_11.third_hop_ds__month AS metric_time__month - , subq_11.third_hop_ds__quarter AS metric_time__quarter - , subq_11.third_hop_ds__year AS metric_time__year - , subq_11.third_hop_ds__extract_year AS metric_time__extract_year - , subq_11.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_11.third_hop_ds__extract_month AS metric_time__extract_month - , subq_11.third_hop_ds__extract_day AS metric_time__extract_day - , subq_11.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_11.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_11.customer_third_hop_id - , subq_11.value - , subq_11.customer_third_hop_id__value - , subq_11.third_hop_count + subq_9.third_hop_ds__day + , subq_9.third_hop_ds__week + , subq_9.third_hop_ds__month + , subq_9.third_hop_ds__quarter + , subq_9.third_hop_ds__year + , subq_9.third_hop_ds__extract_year + , subq_9.third_hop_ds__extract_quarter + , subq_9.third_hop_ds__extract_month + , subq_9.third_hop_ds__extract_day + , subq_9.third_hop_ds__extract_dow + , subq_9.third_hop_ds__extract_doy + , subq_9.customer_third_hop_id__third_hop_ds__day + , subq_9.customer_third_hop_id__third_hop_ds__week + , subq_9.customer_third_hop_id__third_hop_ds__month + , subq_9.customer_third_hop_id__third_hop_ds__quarter + , subq_9.customer_third_hop_id__third_hop_ds__year + , subq_9.customer_third_hop_id__third_hop_ds__extract_year + , subq_9.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_9.customer_third_hop_id__third_hop_ds__extract_month + , subq_9.customer_third_hop_id__third_hop_ds__extract_day + , subq_9.customer_third_hop_id__third_hop_ds__extract_dow + , subq_9.customer_third_hop_id__third_hop_ds__extract_doy + , subq_9.third_hop_ds__day AS metric_time__day + , subq_9.third_hop_ds__week AS metric_time__week + , subq_9.third_hop_ds__month AS metric_time__month + , subq_9.third_hop_ds__quarter AS metric_time__quarter + , subq_9.third_hop_ds__year AS metric_time__year + , subq_9.third_hop_ds__extract_year AS metric_time__extract_year + , subq_9.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_9.third_hop_ds__extract_month AS metric_time__extract_month + , subq_9.third_hop_ds__extract_day AS metric_time__extract_day + , subq_9.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_9.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_9.customer_third_hop_id + , subq_9.value + , subq_9.customer_third_hop_id__value + , subq_9.third_hop_count FROM ( -- Read Elements From Semantic Model 'third_hop_table' SELECT @@ -101,151 +101,151 @@ FROM ( , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy , third_hop_table_src_22000.customer_third_hop_id FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_11 - ) subq_12 - ) subq_13 + ) subq_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_21.customer_id__customer_third_hop_id - , subq_21.customer_id__customer_third_hop_id__paraguayan_customers + subq_19.customer_id__customer_third_hop_id + , subq_19.customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Compute Metrics via Expressions SELECT - subq_20.customer_id__customer_third_hop_id - , subq_20.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_18.customer_id__customer_third_hop_id + , subq_18.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Aggregate Measures SELECT - subq_19.customer_id__customer_third_hop_id - , SUM(subq_19.customers_with_other_data) AS customers_with_other_data + subq_17.customer_id__customer_third_hop_id + , SUM(subq_17.customers_with_other_data) AS customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] SELECT - subq_18.customer_id__customer_third_hop_id - , subq_18.customers_with_other_data + subq_16.customer_id__customer_third_hop_id + , subq_16.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_17.customer_id__customer_third_hop_id - , subq_17.customer_id__country - , subq_17.customers_with_other_data + subq_15.customer_id__customer_third_hop_id + , subq_15.customer_id__country + , subq_15.customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT - subq_16.customer_id__customer_third_hop_id - , subq_16.customer_id__country - , subq_16.customers_with_other_data + subq_14.customer_id__customer_third_hop_id + , subq_14.customer_id__country + , subq_14.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_15.acquired_ds__day - , subq_15.acquired_ds__week - , subq_15.acquired_ds__month - , subq_15.acquired_ds__quarter - , subq_15.acquired_ds__year - , subq_15.acquired_ds__extract_year - , subq_15.acquired_ds__extract_quarter - , subq_15.acquired_ds__extract_month - , subq_15.acquired_ds__extract_day - , subq_15.acquired_ds__extract_dow - , subq_15.acquired_ds__extract_doy - , subq_15.customer_id__acquired_ds__day - , subq_15.customer_id__acquired_ds__week - , subq_15.customer_id__acquired_ds__month - , subq_15.customer_id__acquired_ds__quarter - , subq_15.customer_id__acquired_ds__year - , subq_15.customer_id__acquired_ds__extract_year - , subq_15.customer_id__acquired_ds__extract_quarter - , subq_15.customer_id__acquired_ds__extract_month - , subq_15.customer_id__acquired_ds__extract_day - , subq_15.customer_id__acquired_ds__extract_dow - , subq_15.customer_id__acquired_ds__extract_doy - , subq_15.customer_third_hop_id__acquired_ds__day - , subq_15.customer_third_hop_id__acquired_ds__week - , subq_15.customer_third_hop_id__acquired_ds__month - , subq_15.customer_third_hop_id__acquired_ds__quarter - , subq_15.customer_third_hop_id__acquired_ds__year - , subq_15.customer_third_hop_id__acquired_ds__extract_year - , subq_15.customer_third_hop_id__acquired_ds__extract_quarter - , subq_15.customer_third_hop_id__acquired_ds__extract_month - , subq_15.customer_third_hop_id__acquired_ds__extract_day - , subq_15.customer_third_hop_id__acquired_ds__extract_dow - , subq_15.customer_third_hop_id__acquired_ds__extract_doy - , subq_15.metric_time__day - , subq_15.metric_time__week - , subq_15.metric_time__month - , subq_15.metric_time__quarter - , subq_15.metric_time__year - , subq_15.metric_time__extract_year - , subq_15.metric_time__extract_quarter - , subq_15.metric_time__extract_month - , subq_15.metric_time__extract_day - , subq_15.metric_time__extract_dow - , subq_15.metric_time__extract_doy - , subq_15.customer_id - , subq_15.customer_third_hop_id - , subq_15.customer_id__customer_third_hop_id - , subq_15.customer_third_hop_id__customer_id - , subq_15.country - , subq_15.customer_id__country - , subq_15.customer_third_hop_id__country - , subq_15.customers_with_other_data + subq_13.acquired_ds__day + , subq_13.acquired_ds__week + , subq_13.acquired_ds__month + , subq_13.acquired_ds__quarter + , subq_13.acquired_ds__year + , subq_13.acquired_ds__extract_year + , subq_13.acquired_ds__extract_quarter + , subq_13.acquired_ds__extract_month + , subq_13.acquired_ds__extract_day + , subq_13.acquired_ds__extract_dow + , subq_13.acquired_ds__extract_doy + , subq_13.customer_id__acquired_ds__day + , subq_13.customer_id__acquired_ds__week + , subq_13.customer_id__acquired_ds__month + , subq_13.customer_id__acquired_ds__quarter + , subq_13.customer_id__acquired_ds__year + , subq_13.customer_id__acquired_ds__extract_year + , subq_13.customer_id__acquired_ds__extract_quarter + , subq_13.customer_id__acquired_ds__extract_month + , subq_13.customer_id__acquired_ds__extract_day + , subq_13.customer_id__acquired_ds__extract_dow + , subq_13.customer_id__acquired_ds__extract_doy + , subq_13.customer_third_hop_id__acquired_ds__day + , subq_13.customer_third_hop_id__acquired_ds__week + , subq_13.customer_third_hop_id__acquired_ds__month + , subq_13.customer_third_hop_id__acquired_ds__quarter + , subq_13.customer_third_hop_id__acquired_ds__year + , subq_13.customer_third_hop_id__acquired_ds__extract_year + , subq_13.customer_third_hop_id__acquired_ds__extract_quarter + , subq_13.customer_third_hop_id__acquired_ds__extract_month + , subq_13.customer_third_hop_id__acquired_ds__extract_day + , subq_13.customer_third_hop_id__acquired_ds__extract_dow + , subq_13.customer_third_hop_id__acquired_ds__extract_doy + , subq_13.metric_time__day + , subq_13.metric_time__week + , subq_13.metric_time__month + , subq_13.metric_time__quarter + , subq_13.metric_time__year + , subq_13.metric_time__extract_year + , subq_13.metric_time__extract_quarter + , subq_13.metric_time__extract_month + , subq_13.metric_time__extract_day + , subq_13.metric_time__extract_dow + , subq_13.metric_time__extract_doy + , subq_13.customer_id + , subq_13.customer_third_hop_id + , subq_13.customer_id__customer_third_hop_id + , subq_13.customer_third_hop_id__customer_id + , subq_13.country + , subq_13.customer_id__country + , subq_13.customer_third_hop_id__country + , subq_13.customers_with_other_data FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - subq_14.acquired_ds__day - , subq_14.acquired_ds__week - , subq_14.acquired_ds__month - , subq_14.acquired_ds__quarter - , subq_14.acquired_ds__year - , subq_14.acquired_ds__extract_year - , subq_14.acquired_ds__extract_quarter - , subq_14.acquired_ds__extract_month - , subq_14.acquired_ds__extract_day - , subq_14.acquired_ds__extract_dow - , subq_14.acquired_ds__extract_doy - , subq_14.customer_id__acquired_ds__day - , subq_14.customer_id__acquired_ds__week - , subq_14.customer_id__acquired_ds__month - , subq_14.customer_id__acquired_ds__quarter - , subq_14.customer_id__acquired_ds__year - , subq_14.customer_id__acquired_ds__extract_year - , subq_14.customer_id__acquired_ds__extract_quarter - , subq_14.customer_id__acquired_ds__extract_month - , subq_14.customer_id__acquired_ds__extract_day - , subq_14.customer_id__acquired_ds__extract_dow - , subq_14.customer_id__acquired_ds__extract_doy - , subq_14.customer_third_hop_id__acquired_ds__day - , subq_14.customer_third_hop_id__acquired_ds__week - , subq_14.customer_third_hop_id__acquired_ds__month - , subq_14.customer_third_hop_id__acquired_ds__quarter - , subq_14.customer_third_hop_id__acquired_ds__year - , subq_14.customer_third_hop_id__acquired_ds__extract_year - , subq_14.customer_third_hop_id__acquired_ds__extract_quarter - , subq_14.customer_third_hop_id__acquired_ds__extract_month - , subq_14.customer_third_hop_id__acquired_ds__extract_day - , subq_14.customer_third_hop_id__acquired_ds__extract_dow - , subq_14.customer_third_hop_id__acquired_ds__extract_doy - , subq_14.acquired_ds__day AS metric_time__day - , subq_14.acquired_ds__week AS metric_time__week - , subq_14.acquired_ds__month AS metric_time__month - , subq_14.acquired_ds__quarter AS metric_time__quarter - , subq_14.acquired_ds__year AS metric_time__year - , subq_14.acquired_ds__extract_year AS metric_time__extract_year - , subq_14.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_14.acquired_ds__extract_month AS metric_time__extract_month - , subq_14.acquired_ds__extract_day AS metric_time__extract_day - , subq_14.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_14.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_14.customer_id - , subq_14.customer_third_hop_id - , subq_14.customer_id__customer_third_hop_id - , subq_14.customer_third_hop_id__customer_id - , subq_14.country - , subq_14.customer_id__country - , subq_14.customer_third_hop_id__country - , subq_14.customers_with_other_data + subq_12.acquired_ds__day + , subq_12.acquired_ds__week + , subq_12.acquired_ds__month + , subq_12.acquired_ds__quarter + , subq_12.acquired_ds__year + , subq_12.acquired_ds__extract_year + , subq_12.acquired_ds__extract_quarter + , subq_12.acquired_ds__extract_month + , subq_12.acquired_ds__extract_day + , subq_12.acquired_ds__extract_dow + , subq_12.acquired_ds__extract_doy + , subq_12.customer_id__acquired_ds__day + , subq_12.customer_id__acquired_ds__week + , subq_12.customer_id__acquired_ds__month + , subq_12.customer_id__acquired_ds__quarter + , subq_12.customer_id__acquired_ds__year + , subq_12.customer_id__acquired_ds__extract_year + , subq_12.customer_id__acquired_ds__extract_quarter + , subq_12.customer_id__acquired_ds__extract_month + , subq_12.customer_id__acquired_ds__extract_day + , subq_12.customer_id__acquired_ds__extract_dow + , subq_12.customer_id__acquired_ds__extract_doy + , subq_12.customer_third_hop_id__acquired_ds__day + , subq_12.customer_third_hop_id__acquired_ds__week + , subq_12.customer_third_hop_id__acquired_ds__month + , subq_12.customer_third_hop_id__acquired_ds__quarter + , subq_12.customer_third_hop_id__acquired_ds__year + , subq_12.customer_third_hop_id__acquired_ds__extract_year + , subq_12.customer_third_hop_id__acquired_ds__extract_quarter + , subq_12.customer_third_hop_id__acquired_ds__extract_month + , subq_12.customer_third_hop_id__acquired_ds__extract_day + , subq_12.customer_third_hop_id__acquired_ds__extract_dow + , subq_12.customer_third_hop_id__acquired_ds__extract_doy + , subq_12.acquired_ds__day AS metric_time__day + , subq_12.acquired_ds__week AS metric_time__week + , subq_12.acquired_ds__month AS metric_time__month + , subq_12.acquired_ds__quarter AS metric_time__quarter + , subq_12.acquired_ds__year AS metric_time__year + , subq_12.acquired_ds__extract_year AS metric_time__extract_year + , subq_12.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_12.acquired_ds__extract_month AS metric_time__extract_month + , subq_12.acquired_ds__extract_day AS metric_time__extract_day + , subq_12.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_12.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_12.customer_id + , subq_12.customer_third_hop_id + , subq_12.customer_id__customer_third_hop_id + , subq_12.customer_third_hop_id__customer_id + , subq_12.country + , subq_12.customer_id__country + , subq_12.customer_third_hop_id__country + , subq_12.customers_with_other_data FROM ( -- Read Elements From Semantic Model 'customer_other_data' SELECT @@ -291,24 +291,24 @@ FROM ( , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_14 - ) subq_15 + ) subq_12 + ) subq_13 WHERE customer_id__country = 'paraguay' - ) subq_16 - ) subq_17 + ) subq_14 + ) subq_15 WHERE customer_id__country = 'paraguay' - ) subq_18 - ) subq_19 + ) subq_16 + ) subq_17 GROUP BY - subq_19.customer_id__customer_third_hop_id - ) subq_20 - ) subq_21 - ) subq_22 + subq_17.customer_id__customer_third_hop_id + ) subq_18 + ) subq_19 + ) subq_20 ON - subq_13.customer_third_hop_id = subq_22.customer_id__customer_third_hop_id - ) subq_23 - ) subq_24 + subq_11.customer_third_hop_id = subq_20.customer_id__customer_third_hop_id + ) subq_21 + ) subq_22 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_23 + ) subq_24 +) subq_25 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/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 7c12d6cf98..4af49531fb 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_39.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_37.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -35,14 +35,14 @@ FROM ( , country AS customer_id__country , 1 AS customers_with_other_data FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_32 + ) subq_30 WHERE customer_id__country = 'paraguay' - ) subq_34 + ) subq_32 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_39 + ) subq_37 ON - third_hop_table_src_22000.customer_third_hop_id = subq_39.customer_id__customer_third_hop_id -) subq_41 + third_hop_table_src_22000.customer_third_hop_id = subq_37.customer_id__customer_third_hop_id +) subq_39 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_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 795a470587..7e727a5e96 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_27.third_hop_count + subq_25.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_26.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_24.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_25.third_hop_count + subq_23.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_24.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_24.third_hop_count + subq_22.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_22.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_23.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_23.third_hop_count + subq_21.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_21.third_hop_count FROM ( -- Join Standard Outputs SELECT - subq_13.customer_third_hop_id AS customer_third_hop_id - , subq_22.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id - , subq_22.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_13.third_hop_count AS third_hop_count + subq_11.customer_third_hop_id AS customer_third_hop_id + , subq_20.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_20.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_11.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_12.customer_third_hop_id - , subq_12.third_hop_count + subq_10.customer_third_hop_id + , subq_10.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - subq_11.third_hop_ds__day - , subq_11.third_hop_ds__week - , subq_11.third_hop_ds__month - , subq_11.third_hop_ds__quarter - , subq_11.third_hop_ds__year - , subq_11.third_hop_ds__extract_year - , subq_11.third_hop_ds__extract_quarter - , subq_11.third_hop_ds__extract_month - , subq_11.third_hop_ds__extract_day - , subq_11.third_hop_ds__extract_dow - , subq_11.third_hop_ds__extract_doy - , subq_11.customer_third_hop_id__third_hop_ds__day - , subq_11.customer_third_hop_id__third_hop_ds__week - , subq_11.customer_third_hop_id__third_hop_ds__month - , subq_11.customer_third_hop_id__third_hop_ds__quarter - , subq_11.customer_third_hop_id__third_hop_ds__year - , subq_11.customer_third_hop_id__third_hop_ds__extract_year - , subq_11.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_11.customer_third_hop_id__third_hop_ds__extract_month - , subq_11.customer_third_hop_id__third_hop_ds__extract_day - , subq_11.customer_third_hop_id__third_hop_ds__extract_dow - , subq_11.customer_third_hop_id__third_hop_ds__extract_doy - , subq_11.third_hop_ds__day AS metric_time__day - , subq_11.third_hop_ds__week AS metric_time__week - , subq_11.third_hop_ds__month AS metric_time__month - , subq_11.third_hop_ds__quarter AS metric_time__quarter - , subq_11.third_hop_ds__year AS metric_time__year - , subq_11.third_hop_ds__extract_year AS metric_time__extract_year - , subq_11.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_11.third_hop_ds__extract_month AS metric_time__extract_month - , subq_11.third_hop_ds__extract_day AS metric_time__extract_day - , subq_11.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_11.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_11.customer_third_hop_id - , subq_11.value - , subq_11.customer_third_hop_id__value - , subq_11.third_hop_count + subq_9.third_hop_ds__day + , subq_9.third_hop_ds__week + , subq_9.third_hop_ds__month + , subq_9.third_hop_ds__quarter + , subq_9.third_hop_ds__year + , subq_9.third_hop_ds__extract_year + , subq_9.third_hop_ds__extract_quarter + , subq_9.third_hop_ds__extract_month + , subq_9.third_hop_ds__extract_day + , subq_9.third_hop_ds__extract_dow + , subq_9.third_hop_ds__extract_doy + , subq_9.customer_third_hop_id__third_hop_ds__day + , subq_9.customer_third_hop_id__third_hop_ds__week + , subq_9.customer_third_hop_id__third_hop_ds__month + , subq_9.customer_third_hop_id__third_hop_ds__quarter + , subq_9.customer_third_hop_id__third_hop_ds__year + , subq_9.customer_third_hop_id__third_hop_ds__extract_year + , subq_9.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_9.customer_third_hop_id__third_hop_ds__extract_month + , subq_9.customer_third_hop_id__third_hop_ds__extract_day + , subq_9.customer_third_hop_id__third_hop_ds__extract_dow + , subq_9.customer_third_hop_id__third_hop_ds__extract_doy + , subq_9.third_hop_ds__day AS metric_time__day + , subq_9.third_hop_ds__week AS metric_time__week + , subq_9.third_hop_ds__month AS metric_time__month + , subq_9.third_hop_ds__quarter AS metric_time__quarter + , subq_9.third_hop_ds__year AS metric_time__year + , subq_9.third_hop_ds__extract_year AS metric_time__extract_year + , subq_9.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_9.third_hop_ds__extract_month AS metric_time__extract_month + , subq_9.third_hop_ds__extract_day AS metric_time__extract_day + , subq_9.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_9.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_9.customer_third_hop_id + , subq_9.value + , subq_9.customer_third_hop_id__value + , subq_9.third_hop_count FROM ( -- Read Elements From Semantic Model 'third_hop_table' SELECT @@ -101,151 +101,151 @@ FROM ( , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy , third_hop_table_src_22000.customer_third_hop_id FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_11 - ) subq_12 - ) subq_13 + ) subq_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_21.customer_id__customer_third_hop_id - , subq_21.customer_id__customer_third_hop_id__paraguayan_customers + subq_19.customer_id__customer_third_hop_id + , subq_19.customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Compute Metrics via Expressions SELECT - subq_20.customer_id__customer_third_hop_id - , subq_20.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_18.customer_id__customer_third_hop_id + , subq_18.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Aggregate Measures SELECT - subq_19.customer_id__customer_third_hop_id - , SUM(subq_19.customers_with_other_data) AS customers_with_other_data + subq_17.customer_id__customer_third_hop_id + , SUM(subq_17.customers_with_other_data) AS customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] SELECT - subq_18.customer_id__customer_third_hop_id - , subq_18.customers_with_other_data + subq_16.customer_id__customer_third_hop_id + , subq_16.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_17.customer_id__customer_third_hop_id - , subq_17.customer_id__country - , subq_17.customers_with_other_data + subq_15.customer_id__customer_third_hop_id + , subq_15.customer_id__country + , subq_15.customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT - subq_16.customer_id__customer_third_hop_id - , subq_16.customer_id__country - , subq_16.customers_with_other_data + subq_14.customer_id__customer_third_hop_id + , subq_14.customer_id__country + , subq_14.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_15.acquired_ds__day - , subq_15.acquired_ds__week - , subq_15.acquired_ds__month - , subq_15.acquired_ds__quarter - , subq_15.acquired_ds__year - , subq_15.acquired_ds__extract_year - , subq_15.acquired_ds__extract_quarter - , subq_15.acquired_ds__extract_month - , subq_15.acquired_ds__extract_day - , subq_15.acquired_ds__extract_dow - , subq_15.acquired_ds__extract_doy - , subq_15.customer_id__acquired_ds__day - , subq_15.customer_id__acquired_ds__week - , subq_15.customer_id__acquired_ds__month - , subq_15.customer_id__acquired_ds__quarter - , subq_15.customer_id__acquired_ds__year - , subq_15.customer_id__acquired_ds__extract_year - , subq_15.customer_id__acquired_ds__extract_quarter - , subq_15.customer_id__acquired_ds__extract_month - , subq_15.customer_id__acquired_ds__extract_day - , subq_15.customer_id__acquired_ds__extract_dow - , subq_15.customer_id__acquired_ds__extract_doy - , subq_15.customer_third_hop_id__acquired_ds__day - , subq_15.customer_third_hop_id__acquired_ds__week - , subq_15.customer_third_hop_id__acquired_ds__month - , subq_15.customer_third_hop_id__acquired_ds__quarter - , subq_15.customer_third_hop_id__acquired_ds__year - , subq_15.customer_third_hop_id__acquired_ds__extract_year - , subq_15.customer_third_hop_id__acquired_ds__extract_quarter - , subq_15.customer_third_hop_id__acquired_ds__extract_month - , subq_15.customer_third_hop_id__acquired_ds__extract_day - , subq_15.customer_third_hop_id__acquired_ds__extract_dow - , subq_15.customer_third_hop_id__acquired_ds__extract_doy - , subq_15.metric_time__day - , subq_15.metric_time__week - , subq_15.metric_time__month - , subq_15.metric_time__quarter - , subq_15.metric_time__year - , subq_15.metric_time__extract_year - , subq_15.metric_time__extract_quarter - , subq_15.metric_time__extract_month - , subq_15.metric_time__extract_day - , subq_15.metric_time__extract_dow - , subq_15.metric_time__extract_doy - , subq_15.customer_id - , subq_15.customer_third_hop_id - , subq_15.customer_id__customer_third_hop_id - , subq_15.customer_third_hop_id__customer_id - , subq_15.country - , subq_15.customer_id__country - , subq_15.customer_third_hop_id__country - , subq_15.customers_with_other_data + subq_13.acquired_ds__day + , subq_13.acquired_ds__week + , subq_13.acquired_ds__month + , subq_13.acquired_ds__quarter + , subq_13.acquired_ds__year + , subq_13.acquired_ds__extract_year + , subq_13.acquired_ds__extract_quarter + , subq_13.acquired_ds__extract_month + , subq_13.acquired_ds__extract_day + , subq_13.acquired_ds__extract_dow + , subq_13.acquired_ds__extract_doy + , subq_13.customer_id__acquired_ds__day + , subq_13.customer_id__acquired_ds__week + , subq_13.customer_id__acquired_ds__month + , subq_13.customer_id__acquired_ds__quarter + , subq_13.customer_id__acquired_ds__year + , subq_13.customer_id__acquired_ds__extract_year + , subq_13.customer_id__acquired_ds__extract_quarter + , subq_13.customer_id__acquired_ds__extract_month + , subq_13.customer_id__acquired_ds__extract_day + , subq_13.customer_id__acquired_ds__extract_dow + , subq_13.customer_id__acquired_ds__extract_doy + , subq_13.customer_third_hop_id__acquired_ds__day + , subq_13.customer_third_hop_id__acquired_ds__week + , subq_13.customer_third_hop_id__acquired_ds__month + , subq_13.customer_third_hop_id__acquired_ds__quarter + , subq_13.customer_third_hop_id__acquired_ds__year + , subq_13.customer_third_hop_id__acquired_ds__extract_year + , subq_13.customer_third_hop_id__acquired_ds__extract_quarter + , subq_13.customer_third_hop_id__acquired_ds__extract_month + , subq_13.customer_third_hop_id__acquired_ds__extract_day + , subq_13.customer_third_hop_id__acquired_ds__extract_dow + , subq_13.customer_third_hop_id__acquired_ds__extract_doy + , subq_13.metric_time__day + , subq_13.metric_time__week + , subq_13.metric_time__month + , subq_13.metric_time__quarter + , subq_13.metric_time__year + , subq_13.metric_time__extract_year + , subq_13.metric_time__extract_quarter + , subq_13.metric_time__extract_month + , subq_13.metric_time__extract_day + , subq_13.metric_time__extract_dow + , subq_13.metric_time__extract_doy + , subq_13.customer_id + , subq_13.customer_third_hop_id + , subq_13.customer_id__customer_third_hop_id + , subq_13.customer_third_hop_id__customer_id + , subq_13.country + , subq_13.customer_id__country + , subq_13.customer_third_hop_id__country + , subq_13.customers_with_other_data FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - subq_14.acquired_ds__day - , subq_14.acquired_ds__week - , subq_14.acquired_ds__month - , subq_14.acquired_ds__quarter - , subq_14.acquired_ds__year - , subq_14.acquired_ds__extract_year - , subq_14.acquired_ds__extract_quarter - , subq_14.acquired_ds__extract_month - , subq_14.acquired_ds__extract_day - , subq_14.acquired_ds__extract_dow - , subq_14.acquired_ds__extract_doy - , subq_14.customer_id__acquired_ds__day - , subq_14.customer_id__acquired_ds__week - , subq_14.customer_id__acquired_ds__month - , subq_14.customer_id__acquired_ds__quarter - , subq_14.customer_id__acquired_ds__year - , subq_14.customer_id__acquired_ds__extract_year - , subq_14.customer_id__acquired_ds__extract_quarter - , subq_14.customer_id__acquired_ds__extract_month - , subq_14.customer_id__acquired_ds__extract_day - , subq_14.customer_id__acquired_ds__extract_dow - , subq_14.customer_id__acquired_ds__extract_doy - , subq_14.customer_third_hop_id__acquired_ds__day - , subq_14.customer_third_hop_id__acquired_ds__week - , subq_14.customer_third_hop_id__acquired_ds__month - , subq_14.customer_third_hop_id__acquired_ds__quarter - , subq_14.customer_third_hop_id__acquired_ds__year - , subq_14.customer_third_hop_id__acquired_ds__extract_year - , subq_14.customer_third_hop_id__acquired_ds__extract_quarter - , subq_14.customer_third_hop_id__acquired_ds__extract_month - , subq_14.customer_third_hop_id__acquired_ds__extract_day - , subq_14.customer_third_hop_id__acquired_ds__extract_dow - , subq_14.customer_third_hop_id__acquired_ds__extract_doy - , subq_14.acquired_ds__day AS metric_time__day - , subq_14.acquired_ds__week AS metric_time__week - , subq_14.acquired_ds__month AS metric_time__month - , subq_14.acquired_ds__quarter AS metric_time__quarter - , subq_14.acquired_ds__year AS metric_time__year - , subq_14.acquired_ds__extract_year AS metric_time__extract_year - , subq_14.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_14.acquired_ds__extract_month AS metric_time__extract_month - , subq_14.acquired_ds__extract_day AS metric_time__extract_day - , subq_14.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_14.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_14.customer_id - , subq_14.customer_third_hop_id - , subq_14.customer_id__customer_third_hop_id - , subq_14.customer_third_hop_id__customer_id - , subq_14.country - , subq_14.customer_id__country - , subq_14.customer_third_hop_id__country - , subq_14.customers_with_other_data + subq_12.acquired_ds__day + , subq_12.acquired_ds__week + , subq_12.acquired_ds__month + , subq_12.acquired_ds__quarter + , subq_12.acquired_ds__year + , subq_12.acquired_ds__extract_year + , subq_12.acquired_ds__extract_quarter + , subq_12.acquired_ds__extract_month + , subq_12.acquired_ds__extract_day + , subq_12.acquired_ds__extract_dow + , subq_12.acquired_ds__extract_doy + , subq_12.customer_id__acquired_ds__day + , subq_12.customer_id__acquired_ds__week + , subq_12.customer_id__acquired_ds__month + , subq_12.customer_id__acquired_ds__quarter + , subq_12.customer_id__acquired_ds__year + , subq_12.customer_id__acquired_ds__extract_year + , subq_12.customer_id__acquired_ds__extract_quarter + , subq_12.customer_id__acquired_ds__extract_month + , subq_12.customer_id__acquired_ds__extract_day + , subq_12.customer_id__acquired_ds__extract_dow + , subq_12.customer_id__acquired_ds__extract_doy + , subq_12.customer_third_hop_id__acquired_ds__day + , subq_12.customer_third_hop_id__acquired_ds__week + , subq_12.customer_third_hop_id__acquired_ds__month + , subq_12.customer_third_hop_id__acquired_ds__quarter + , subq_12.customer_third_hop_id__acquired_ds__year + , subq_12.customer_third_hop_id__acquired_ds__extract_year + , subq_12.customer_third_hop_id__acquired_ds__extract_quarter + , subq_12.customer_third_hop_id__acquired_ds__extract_month + , subq_12.customer_third_hop_id__acquired_ds__extract_day + , subq_12.customer_third_hop_id__acquired_ds__extract_dow + , subq_12.customer_third_hop_id__acquired_ds__extract_doy + , subq_12.acquired_ds__day AS metric_time__day + , subq_12.acquired_ds__week AS metric_time__week + , subq_12.acquired_ds__month AS metric_time__month + , subq_12.acquired_ds__quarter AS metric_time__quarter + , subq_12.acquired_ds__year AS metric_time__year + , subq_12.acquired_ds__extract_year AS metric_time__extract_year + , subq_12.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_12.acquired_ds__extract_month AS metric_time__extract_month + , subq_12.acquired_ds__extract_day AS metric_time__extract_day + , subq_12.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_12.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_12.customer_id + , subq_12.customer_third_hop_id + , subq_12.customer_id__customer_third_hop_id + , subq_12.customer_third_hop_id__customer_id + , subq_12.country + , subq_12.customer_id__country + , subq_12.customer_third_hop_id__country + , subq_12.customers_with_other_data FROM ( -- Read Elements From Semantic Model 'customer_other_data' SELECT @@ -291,24 +291,24 @@ FROM ( , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_14 - ) subq_15 + ) subq_12 + ) subq_13 WHERE customer_id__country = 'paraguay' - ) subq_16 - ) subq_17 + ) subq_14 + ) subq_15 WHERE customer_id__country = 'paraguay' - ) subq_18 - ) subq_19 + ) subq_16 + ) subq_17 GROUP BY - subq_19.customer_id__customer_third_hop_id - ) subq_20 - ) subq_21 - ) subq_22 + subq_17.customer_id__customer_third_hop_id + ) subq_18 + ) subq_19 + ) subq_20 ON - subq_13.customer_third_hop_id = subq_22.customer_id__customer_third_hop_id - ) subq_23 - ) subq_24 + subq_11.customer_third_hop_id = subq_20.customer_id__customer_third_hop_id + ) subq_21 + ) subq_22 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_23 + ) subq_24 +) subq_25 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/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 7c12d6cf98..4af49531fb 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_39.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_37.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -35,14 +35,14 @@ FROM ( , country AS customer_id__country , 1 AS customers_with_other_data FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_32 + ) subq_30 WHERE customer_id__country = 'paraguay' - ) subq_34 + ) subq_32 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_39 + ) subq_37 ON - third_hop_table_src_22000.customer_third_hop_id = subq_39.customer_id__customer_third_hop_id -) subq_41 + third_hop_table_src_22000.customer_third_hop_id = subq_37.customer_id__customer_third_hop_id +) subq_39 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_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 deeac7d968..10fba73707 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_27.third_hop_count + subq_25.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_26.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_24.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_25.third_hop_count + subq_23.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_24.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_24.third_hop_count + subq_22.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_22.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_23.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_23.third_hop_count + subq_21.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_21.third_hop_count FROM ( -- Join Standard Outputs SELECT - subq_13.customer_third_hop_id AS customer_third_hop_id - , subq_22.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id - , subq_22.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_13.third_hop_count AS third_hop_count + subq_11.customer_third_hop_id AS customer_third_hop_id + , subq_20.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_20.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_11.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_12.customer_third_hop_id - , subq_12.third_hop_count + subq_10.customer_third_hop_id + , subq_10.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - subq_11.third_hop_ds__day - , subq_11.third_hop_ds__week - , subq_11.third_hop_ds__month - , subq_11.third_hop_ds__quarter - , subq_11.third_hop_ds__year - , subq_11.third_hop_ds__extract_year - , subq_11.third_hop_ds__extract_quarter - , subq_11.third_hop_ds__extract_month - , subq_11.third_hop_ds__extract_day - , subq_11.third_hop_ds__extract_dow - , subq_11.third_hop_ds__extract_doy - , subq_11.customer_third_hop_id__third_hop_ds__day - , subq_11.customer_third_hop_id__third_hop_ds__week - , subq_11.customer_third_hop_id__third_hop_ds__month - , subq_11.customer_third_hop_id__third_hop_ds__quarter - , subq_11.customer_third_hop_id__third_hop_ds__year - , subq_11.customer_third_hop_id__third_hop_ds__extract_year - , subq_11.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_11.customer_third_hop_id__third_hop_ds__extract_month - , subq_11.customer_third_hop_id__third_hop_ds__extract_day - , subq_11.customer_third_hop_id__third_hop_ds__extract_dow - , subq_11.customer_third_hop_id__third_hop_ds__extract_doy - , subq_11.third_hop_ds__day AS metric_time__day - , subq_11.third_hop_ds__week AS metric_time__week - , subq_11.third_hop_ds__month AS metric_time__month - , subq_11.third_hop_ds__quarter AS metric_time__quarter - , subq_11.third_hop_ds__year AS metric_time__year - , subq_11.third_hop_ds__extract_year AS metric_time__extract_year - , subq_11.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_11.third_hop_ds__extract_month AS metric_time__extract_month - , subq_11.third_hop_ds__extract_day AS metric_time__extract_day - , subq_11.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_11.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_11.customer_third_hop_id - , subq_11.value - , subq_11.customer_third_hop_id__value - , subq_11.third_hop_count + subq_9.third_hop_ds__day + , subq_9.third_hop_ds__week + , subq_9.third_hop_ds__month + , subq_9.third_hop_ds__quarter + , subq_9.third_hop_ds__year + , subq_9.third_hop_ds__extract_year + , subq_9.third_hop_ds__extract_quarter + , subq_9.third_hop_ds__extract_month + , subq_9.third_hop_ds__extract_day + , subq_9.third_hop_ds__extract_dow + , subq_9.third_hop_ds__extract_doy + , subq_9.customer_third_hop_id__third_hop_ds__day + , subq_9.customer_third_hop_id__third_hop_ds__week + , subq_9.customer_third_hop_id__third_hop_ds__month + , subq_9.customer_third_hop_id__third_hop_ds__quarter + , subq_9.customer_third_hop_id__third_hop_ds__year + , subq_9.customer_third_hop_id__third_hop_ds__extract_year + , subq_9.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_9.customer_third_hop_id__third_hop_ds__extract_month + , subq_9.customer_third_hop_id__third_hop_ds__extract_day + , subq_9.customer_third_hop_id__third_hop_ds__extract_dow + , subq_9.customer_third_hop_id__third_hop_ds__extract_doy + , subq_9.third_hop_ds__day AS metric_time__day + , subq_9.third_hop_ds__week AS metric_time__week + , subq_9.third_hop_ds__month AS metric_time__month + , subq_9.third_hop_ds__quarter AS metric_time__quarter + , subq_9.third_hop_ds__year AS metric_time__year + , subq_9.third_hop_ds__extract_year AS metric_time__extract_year + , subq_9.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_9.third_hop_ds__extract_month AS metric_time__extract_month + , subq_9.third_hop_ds__extract_day AS metric_time__extract_day + , subq_9.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_9.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_9.customer_third_hop_id + , subq_9.value + , subq_9.customer_third_hop_id__value + , subq_9.third_hop_count FROM ( -- Read Elements From Semantic Model 'third_hop_table' SELECT @@ -101,151 +101,151 @@ FROM ( , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy , third_hop_table_src_22000.customer_third_hop_id FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_11 - ) subq_12 - ) subq_13 + ) subq_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_21.customer_id__customer_third_hop_id - , subq_21.customer_id__customer_third_hop_id__paraguayan_customers + subq_19.customer_id__customer_third_hop_id + , subq_19.customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Compute Metrics via Expressions SELECT - subq_20.customer_id__customer_third_hop_id - , subq_20.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_18.customer_id__customer_third_hop_id + , subq_18.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Aggregate Measures SELECT - subq_19.customer_id__customer_third_hop_id - , SUM(subq_19.customers_with_other_data) AS customers_with_other_data + subq_17.customer_id__customer_third_hop_id + , SUM(subq_17.customers_with_other_data) AS customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] SELECT - subq_18.customer_id__customer_third_hop_id - , subq_18.customers_with_other_data + subq_16.customer_id__customer_third_hop_id + , subq_16.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_17.customer_id__customer_third_hop_id - , subq_17.customer_id__country - , subq_17.customers_with_other_data + subq_15.customer_id__customer_third_hop_id + , subq_15.customer_id__country + , subq_15.customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT - subq_16.customer_id__customer_third_hop_id - , subq_16.customer_id__country - , subq_16.customers_with_other_data + subq_14.customer_id__customer_third_hop_id + , subq_14.customer_id__country + , subq_14.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_15.acquired_ds__day - , subq_15.acquired_ds__week - , subq_15.acquired_ds__month - , subq_15.acquired_ds__quarter - , subq_15.acquired_ds__year - , subq_15.acquired_ds__extract_year - , subq_15.acquired_ds__extract_quarter - , subq_15.acquired_ds__extract_month - , subq_15.acquired_ds__extract_day - , subq_15.acquired_ds__extract_dow - , subq_15.acquired_ds__extract_doy - , subq_15.customer_id__acquired_ds__day - , subq_15.customer_id__acquired_ds__week - , subq_15.customer_id__acquired_ds__month - , subq_15.customer_id__acquired_ds__quarter - , subq_15.customer_id__acquired_ds__year - , subq_15.customer_id__acquired_ds__extract_year - , subq_15.customer_id__acquired_ds__extract_quarter - , subq_15.customer_id__acquired_ds__extract_month - , subq_15.customer_id__acquired_ds__extract_day - , subq_15.customer_id__acquired_ds__extract_dow - , subq_15.customer_id__acquired_ds__extract_doy - , subq_15.customer_third_hop_id__acquired_ds__day - , subq_15.customer_third_hop_id__acquired_ds__week - , subq_15.customer_third_hop_id__acquired_ds__month - , subq_15.customer_third_hop_id__acquired_ds__quarter - , subq_15.customer_third_hop_id__acquired_ds__year - , subq_15.customer_third_hop_id__acquired_ds__extract_year - , subq_15.customer_third_hop_id__acquired_ds__extract_quarter - , subq_15.customer_third_hop_id__acquired_ds__extract_month - , subq_15.customer_third_hop_id__acquired_ds__extract_day - , subq_15.customer_third_hop_id__acquired_ds__extract_dow - , subq_15.customer_third_hop_id__acquired_ds__extract_doy - , subq_15.metric_time__day - , subq_15.metric_time__week - , subq_15.metric_time__month - , subq_15.metric_time__quarter - , subq_15.metric_time__year - , subq_15.metric_time__extract_year - , subq_15.metric_time__extract_quarter - , subq_15.metric_time__extract_month - , subq_15.metric_time__extract_day - , subq_15.metric_time__extract_dow - , subq_15.metric_time__extract_doy - , subq_15.customer_id - , subq_15.customer_third_hop_id - , subq_15.customer_id__customer_third_hop_id - , subq_15.customer_third_hop_id__customer_id - , subq_15.country - , subq_15.customer_id__country - , subq_15.customer_third_hop_id__country - , subq_15.customers_with_other_data + subq_13.acquired_ds__day + , subq_13.acquired_ds__week + , subq_13.acquired_ds__month + , subq_13.acquired_ds__quarter + , subq_13.acquired_ds__year + , subq_13.acquired_ds__extract_year + , subq_13.acquired_ds__extract_quarter + , subq_13.acquired_ds__extract_month + , subq_13.acquired_ds__extract_day + , subq_13.acquired_ds__extract_dow + , subq_13.acquired_ds__extract_doy + , subq_13.customer_id__acquired_ds__day + , subq_13.customer_id__acquired_ds__week + , subq_13.customer_id__acquired_ds__month + , subq_13.customer_id__acquired_ds__quarter + , subq_13.customer_id__acquired_ds__year + , subq_13.customer_id__acquired_ds__extract_year + , subq_13.customer_id__acquired_ds__extract_quarter + , subq_13.customer_id__acquired_ds__extract_month + , subq_13.customer_id__acquired_ds__extract_day + , subq_13.customer_id__acquired_ds__extract_dow + , subq_13.customer_id__acquired_ds__extract_doy + , subq_13.customer_third_hop_id__acquired_ds__day + , subq_13.customer_third_hop_id__acquired_ds__week + , subq_13.customer_third_hop_id__acquired_ds__month + , subq_13.customer_third_hop_id__acquired_ds__quarter + , subq_13.customer_third_hop_id__acquired_ds__year + , subq_13.customer_third_hop_id__acquired_ds__extract_year + , subq_13.customer_third_hop_id__acquired_ds__extract_quarter + , subq_13.customer_third_hop_id__acquired_ds__extract_month + , subq_13.customer_third_hop_id__acquired_ds__extract_day + , subq_13.customer_third_hop_id__acquired_ds__extract_dow + , subq_13.customer_third_hop_id__acquired_ds__extract_doy + , subq_13.metric_time__day + , subq_13.metric_time__week + , subq_13.metric_time__month + , subq_13.metric_time__quarter + , subq_13.metric_time__year + , subq_13.metric_time__extract_year + , subq_13.metric_time__extract_quarter + , subq_13.metric_time__extract_month + , subq_13.metric_time__extract_day + , subq_13.metric_time__extract_dow + , subq_13.metric_time__extract_doy + , subq_13.customer_id + , subq_13.customer_third_hop_id + , subq_13.customer_id__customer_third_hop_id + , subq_13.customer_third_hop_id__customer_id + , subq_13.country + , subq_13.customer_id__country + , subq_13.customer_third_hop_id__country + , subq_13.customers_with_other_data FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - subq_14.acquired_ds__day - , subq_14.acquired_ds__week - , subq_14.acquired_ds__month - , subq_14.acquired_ds__quarter - , subq_14.acquired_ds__year - , subq_14.acquired_ds__extract_year - , subq_14.acquired_ds__extract_quarter - , subq_14.acquired_ds__extract_month - , subq_14.acquired_ds__extract_day - , subq_14.acquired_ds__extract_dow - , subq_14.acquired_ds__extract_doy - , subq_14.customer_id__acquired_ds__day - , subq_14.customer_id__acquired_ds__week - , subq_14.customer_id__acquired_ds__month - , subq_14.customer_id__acquired_ds__quarter - , subq_14.customer_id__acquired_ds__year - , subq_14.customer_id__acquired_ds__extract_year - , subq_14.customer_id__acquired_ds__extract_quarter - , subq_14.customer_id__acquired_ds__extract_month - , subq_14.customer_id__acquired_ds__extract_day - , subq_14.customer_id__acquired_ds__extract_dow - , subq_14.customer_id__acquired_ds__extract_doy - , subq_14.customer_third_hop_id__acquired_ds__day - , subq_14.customer_third_hop_id__acquired_ds__week - , subq_14.customer_third_hop_id__acquired_ds__month - , subq_14.customer_third_hop_id__acquired_ds__quarter - , subq_14.customer_third_hop_id__acquired_ds__year - , subq_14.customer_third_hop_id__acquired_ds__extract_year - , subq_14.customer_third_hop_id__acquired_ds__extract_quarter - , subq_14.customer_third_hop_id__acquired_ds__extract_month - , subq_14.customer_third_hop_id__acquired_ds__extract_day - , subq_14.customer_third_hop_id__acquired_ds__extract_dow - , subq_14.customer_third_hop_id__acquired_ds__extract_doy - , subq_14.acquired_ds__day AS metric_time__day - , subq_14.acquired_ds__week AS metric_time__week - , subq_14.acquired_ds__month AS metric_time__month - , subq_14.acquired_ds__quarter AS metric_time__quarter - , subq_14.acquired_ds__year AS metric_time__year - , subq_14.acquired_ds__extract_year AS metric_time__extract_year - , subq_14.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_14.acquired_ds__extract_month AS metric_time__extract_month - , subq_14.acquired_ds__extract_day AS metric_time__extract_day - , subq_14.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_14.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_14.customer_id - , subq_14.customer_third_hop_id - , subq_14.customer_id__customer_third_hop_id - , subq_14.customer_third_hop_id__customer_id - , subq_14.country - , subq_14.customer_id__country - , subq_14.customer_third_hop_id__country - , subq_14.customers_with_other_data + subq_12.acquired_ds__day + , subq_12.acquired_ds__week + , subq_12.acquired_ds__month + , subq_12.acquired_ds__quarter + , subq_12.acquired_ds__year + , subq_12.acquired_ds__extract_year + , subq_12.acquired_ds__extract_quarter + , subq_12.acquired_ds__extract_month + , subq_12.acquired_ds__extract_day + , subq_12.acquired_ds__extract_dow + , subq_12.acquired_ds__extract_doy + , subq_12.customer_id__acquired_ds__day + , subq_12.customer_id__acquired_ds__week + , subq_12.customer_id__acquired_ds__month + , subq_12.customer_id__acquired_ds__quarter + , subq_12.customer_id__acquired_ds__year + , subq_12.customer_id__acquired_ds__extract_year + , subq_12.customer_id__acquired_ds__extract_quarter + , subq_12.customer_id__acquired_ds__extract_month + , subq_12.customer_id__acquired_ds__extract_day + , subq_12.customer_id__acquired_ds__extract_dow + , subq_12.customer_id__acquired_ds__extract_doy + , subq_12.customer_third_hop_id__acquired_ds__day + , subq_12.customer_third_hop_id__acquired_ds__week + , subq_12.customer_third_hop_id__acquired_ds__month + , subq_12.customer_third_hop_id__acquired_ds__quarter + , subq_12.customer_third_hop_id__acquired_ds__year + , subq_12.customer_third_hop_id__acquired_ds__extract_year + , subq_12.customer_third_hop_id__acquired_ds__extract_quarter + , subq_12.customer_third_hop_id__acquired_ds__extract_month + , subq_12.customer_third_hop_id__acquired_ds__extract_day + , subq_12.customer_third_hop_id__acquired_ds__extract_dow + , subq_12.customer_third_hop_id__acquired_ds__extract_doy + , subq_12.acquired_ds__day AS metric_time__day + , subq_12.acquired_ds__week AS metric_time__week + , subq_12.acquired_ds__month AS metric_time__month + , subq_12.acquired_ds__quarter AS metric_time__quarter + , subq_12.acquired_ds__year AS metric_time__year + , subq_12.acquired_ds__extract_year AS metric_time__extract_year + , subq_12.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_12.acquired_ds__extract_month AS metric_time__extract_month + , subq_12.acquired_ds__extract_day AS metric_time__extract_day + , subq_12.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_12.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_12.customer_id + , subq_12.customer_third_hop_id + , subq_12.customer_id__customer_third_hop_id + , subq_12.customer_third_hop_id__customer_id + , subq_12.country + , subq_12.customer_id__country + , subq_12.customer_third_hop_id__country + , subq_12.customers_with_other_data FROM ( -- Read Elements From Semantic Model 'customer_other_data' SELECT @@ -291,24 +291,24 @@ FROM ( , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_14 - ) subq_15 + ) subq_12 + ) subq_13 WHERE customer_id__country = 'paraguay' - ) subq_16 - ) subq_17 + ) subq_14 + ) subq_15 WHERE customer_id__country = 'paraguay' - ) subq_18 - ) subq_19 + ) subq_16 + ) subq_17 GROUP BY - subq_19.customer_id__customer_third_hop_id - ) subq_20 - ) subq_21 - ) subq_22 + subq_17.customer_id__customer_third_hop_id + ) subq_18 + ) subq_19 + ) subq_20 ON - subq_13.customer_third_hop_id = subq_22.customer_id__customer_third_hop_id - ) subq_23 - ) subq_24 + subq_11.customer_third_hop_id = subq_20.customer_id__customer_third_hop_id + ) subq_21 + ) subq_22 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_23 + ) subq_24 +) subq_25 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/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 7c12d6cf98..4af49531fb 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_39.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_37.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -35,14 +35,14 @@ FROM ( , country AS customer_id__country , 1 AS customers_with_other_data FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_32 + ) subq_30 WHERE customer_id__country = 'paraguay' - ) subq_34 + ) subq_32 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_39 + ) subq_37 ON - third_hop_table_src_22000.customer_third_hop_id = subq_39.customer_id__customer_third_hop_id -) subq_41 + third_hop_table_src_22000.customer_third_hop_id = subq_37.customer_id__customer_third_hop_id +) subq_39 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_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 3e8a0a8f2a..fb72540d6e 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_27.third_hop_count + subq_25.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_26.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_24.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_25.third_hop_count + subq_23.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_24.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_24.third_hop_count + subq_22.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_22.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_23.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_23.third_hop_count + subq_21.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_21.third_hop_count FROM ( -- Join Standard Outputs SELECT - subq_13.customer_third_hop_id AS customer_third_hop_id - , subq_22.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id - , subq_22.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_13.third_hop_count AS third_hop_count + subq_11.customer_third_hop_id AS customer_third_hop_id + , subq_20.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_20.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_11.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_12.customer_third_hop_id - , subq_12.third_hop_count + subq_10.customer_third_hop_id + , subq_10.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - subq_11.third_hop_ds__day - , subq_11.third_hop_ds__week - , subq_11.third_hop_ds__month - , subq_11.third_hop_ds__quarter - , subq_11.third_hop_ds__year - , subq_11.third_hop_ds__extract_year - , subq_11.third_hop_ds__extract_quarter - , subq_11.third_hop_ds__extract_month - , subq_11.third_hop_ds__extract_day - , subq_11.third_hop_ds__extract_dow - , subq_11.third_hop_ds__extract_doy - , subq_11.customer_third_hop_id__third_hop_ds__day - , subq_11.customer_third_hop_id__third_hop_ds__week - , subq_11.customer_third_hop_id__third_hop_ds__month - , subq_11.customer_third_hop_id__third_hop_ds__quarter - , subq_11.customer_third_hop_id__third_hop_ds__year - , subq_11.customer_third_hop_id__third_hop_ds__extract_year - , subq_11.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_11.customer_third_hop_id__third_hop_ds__extract_month - , subq_11.customer_third_hop_id__third_hop_ds__extract_day - , subq_11.customer_third_hop_id__third_hop_ds__extract_dow - , subq_11.customer_third_hop_id__third_hop_ds__extract_doy - , subq_11.third_hop_ds__day AS metric_time__day - , subq_11.third_hop_ds__week AS metric_time__week - , subq_11.third_hop_ds__month AS metric_time__month - , subq_11.third_hop_ds__quarter AS metric_time__quarter - , subq_11.third_hop_ds__year AS metric_time__year - , subq_11.third_hop_ds__extract_year AS metric_time__extract_year - , subq_11.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_11.third_hop_ds__extract_month AS metric_time__extract_month - , subq_11.third_hop_ds__extract_day AS metric_time__extract_day - , subq_11.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_11.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_11.customer_third_hop_id - , subq_11.value - , subq_11.customer_third_hop_id__value - , subq_11.third_hop_count + subq_9.third_hop_ds__day + , subq_9.third_hop_ds__week + , subq_9.third_hop_ds__month + , subq_9.third_hop_ds__quarter + , subq_9.third_hop_ds__year + , subq_9.third_hop_ds__extract_year + , subq_9.third_hop_ds__extract_quarter + , subq_9.third_hop_ds__extract_month + , subq_9.third_hop_ds__extract_day + , subq_9.third_hop_ds__extract_dow + , subq_9.third_hop_ds__extract_doy + , subq_9.customer_third_hop_id__third_hop_ds__day + , subq_9.customer_third_hop_id__third_hop_ds__week + , subq_9.customer_third_hop_id__third_hop_ds__month + , subq_9.customer_third_hop_id__third_hop_ds__quarter + , subq_9.customer_third_hop_id__third_hop_ds__year + , subq_9.customer_third_hop_id__third_hop_ds__extract_year + , subq_9.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_9.customer_third_hop_id__third_hop_ds__extract_month + , subq_9.customer_third_hop_id__third_hop_ds__extract_day + , subq_9.customer_third_hop_id__third_hop_ds__extract_dow + , subq_9.customer_third_hop_id__third_hop_ds__extract_doy + , subq_9.third_hop_ds__day AS metric_time__day + , subq_9.third_hop_ds__week AS metric_time__week + , subq_9.third_hop_ds__month AS metric_time__month + , subq_9.third_hop_ds__quarter AS metric_time__quarter + , subq_9.third_hop_ds__year AS metric_time__year + , subq_9.third_hop_ds__extract_year AS metric_time__extract_year + , subq_9.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_9.third_hop_ds__extract_month AS metric_time__extract_month + , subq_9.third_hop_ds__extract_day AS metric_time__extract_day + , subq_9.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_9.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_9.customer_third_hop_id + , subq_9.value + , subq_9.customer_third_hop_id__value + , subq_9.third_hop_count FROM ( -- Read Elements From Semantic Model 'third_hop_table' SELECT @@ -101,151 +101,151 @@ FROM ( , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy , third_hop_table_src_22000.customer_third_hop_id FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_11 - ) subq_12 - ) subq_13 + ) subq_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_21.customer_id__customer_third_hop_id - , subq_21.customer_id__customer_third_hop_id__paraguayan_customers + subq_19.customer_id__customer_third_hop_id + , subq_19.customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Compute Metrics via Expressions SELECT - subq_20.customer_id__customer_third_hop_id - , subq_20.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_18.customer_id__customer_third_hop_id + , subq_18.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Aggregate Measures SELECT - subq_19.customer_id__customer_third_hop_id - , SUM(subq_19.customers_with_other_data) AS customers_with_other_data + subq_17.customer_id__customer_third_hop_id + , SUM(subq_17.customers_with_other_data) AS customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] SELECT - subq_18.customer_id__customer_third_hop_id - , subq_18.customers_with_other_data + subq_16.customer_id__customer_third_hop_id + , subq_16.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_17.customer_id__customer_third_hop_id - , subq_17.customer_id__country - , subq_17.customers_with_other_data + subq_15.customer_id__customer_third_hop_id + , subq_15.customer_id__country + , subq_15.customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT - subq_16.customer_id__customer_third_hop_id - , subq_16.customer_id__country - , subq_16.customers_with_other_data + subq_14.customer_id__customer_third_hop_id + , subq_14.customer_id__country + , subq_14.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_15.acquired_ds__day - , subq_15.acquired_ds__week - , subq_15.acquired_ds__month - , subq_15.acquired_ds__quarter - , subq_15.acquired_ds__year - , subq_15.acquired_ds__extract_year - , subq_15.acquired_ds__extract_quarter - , subq_15.acquired_ds__extract_month - , subq_15.acquired_ds__extract_day - , subq_15.acquired_ds__extract_dow - , subq_15.acquired_ds__extract_doy - , subq_15.customer_id__acquired_ds__day - , subq_15.customer_id__acquired_ds__week - , subq_15.customer_id__acquired_ds__month - , subq_15.customer_id__acquired_ds__quarter - , subq_15.customer_id__acquired_ds__year - , subq_15.customer_id__acquired_ds__extract_year - , subq_15.customer_id__acquired_ds__extract_quarter - , subq_15.customer_id__acquired_ds__extract_month - , subq_15.customer_id__acquired_ds__extract_day - , subq_15.customer_id__acquired_ds__extract_dow - , subq_15.customer_id__acquired_ds__extract_doy - , subq_15.customer_third_hop_id__acquired_ds__day - , subq_15.customer_third_hop_id__acquired_ds__week - , subq_15.customer_third_hop_id__acquired_ds__month - , subq_15.customer_third_hop_id__acquired_ds__quarter - , subq_15.customer_third_hop_id__acquired_ds__year - , subq_15.customer_third_hop_id__acquired_ds__extract_year - , subq_15.customer_third_hop_id__acquired_ds__extract_quarter - , subq_15.customer_third_hop_id__acquired_ds__extract_month - , subq_15.customer_third_hop_id__acquired_ds__extract_day - , subq_15.customer_third_hop_id__acquired_ds__extract_dow - , subq_15.customer_third_hop_id__acquired_ds__extract_doy - , subq_15.metric_time__day - , subq_15.metric_time__week - , subq_15.metric_time__month - , subq_15.metric_time__quarter - , subq_15.metric_time__year - , subq_15.metric_time__extract_year - , subq_15.metric_time__extract_quarter - , subq_15.metric_time__extract_month - , subq_15.metric_time__extract_day - , subq_15.metric_time__extract_dow - , subq_15.metric_time__extract_doy - , subq_15.customer_id - , subq_15.customer_third_hop_id - , subq_15.customer_id__customer_third_hop_id - , subq_15.customer_third_hop_id__customer_id - , subq_15.country - , subq_15.customer_id__country - , subq_15.customer_third_hop_id__country - , subq_15.customers_with_other_data + subq_13.acquired_ds__day + , subq_13.acquired_ds__week + , subq_13.acquired_ds__month + , subq_13.acquired_ds__quarter + , subq_13.acquired_ds__year + , subq_13.acquired_ds__extract_year + , subq_13.acquired_ds__extract_quarter + , subq_13.acquired_ds__extract_month + , subq_13.acquired_ds__extract_day + , subq_13.acquired_ds__extract_dow + , subq_13.acquired_ds__extract_doy + , subq_13.customer_id__acquired_ds__day + , subq_13.customer_id__acquired_ds__week + , subq_13.customer_id__acquired_ds__month + , subq_13.customer_id__acquired_ds__quarter + , subq_13.customer_id__acquired_ds__year + , subq_13.customer_id__acquired_ds__extract_year + , subq_13.customer_id__acquired_ds__extract_quarter + , subq_13.customer_id__acquired_ds__extract_month + , subq_13.customer_id__acquired_ds__extract_day + , subq_13.customer_id__acquired_ds__extract_dow + , subq_13.customer_id__acquired_ds__extract_doy + , subq_13.customer_third_hop_id__acquired_ds__day + , subq_13.customer_third_hop_id__acquired_ds__week + , subq_13.customer_third_hop_id__acquired_ds__month + , subq_13.customer_third_hop_id__acquired_ds__quarter + , subq_13.customer_third_hop_id__acquired_ds__year + , subq_13.customer_third_hop_id__acquired_ds__extract_year + , subq_13.customer_third_hop_id__acquired_ds__extract_quarter + , subq_13.customer_third_hop_id__acquired_ds__extract_month + , subq_13.customer_third_hop_id__acquired_ds__extract_day + , subq_13.customer_third_hop_id__acquired_ds__extract_dow + , subq_13.customer_third_hop_id__acquired_ds__extract_doy + , subq_13.metric_time__day + , subq_13.metric_time__week + , subq_13.metric_time__month + , subq_13.metric_time__quarter + , subq_13.metric_time__year + , subq_13.metric_time__extract_year + , subq_13.metric_time__extract_quarter + , subq_13.metric_time__extract_month + , subq_13.metric_time__extract_day + , subq_13.metric_time__extract_dow + , subq_13.metric_time__extract_doy + , subq_13.customer_id + , subq_13.customer_third_hop_id + , subq_13.customer_id__customer_third_hop_id + , subq_13.customer_third_hop_id__customer_id + , subq_13.country + , subq_13.customer_id__country + , subq_13.customer_third_hop_id__country + , subq_13.customers_with_other_data FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - subq_14.acquired_ds__day - , subq_14.acquired_ds__week - , subq_14.acquired_ds__month - , subq_14.acquired_ds__quarter - , subq_14.acquired_ds__year - , subq_14.acquired_ds__extract_year - , subq_14.acquired_ds__extract_quarter - , subq_14.acquired_ds__extract_month - , subq_14.acquired_ds__extract_day - , subq_14.acquired_ds__extract_dow - , subq_14.acquired_ds__extract_doy - , subq_14.customer_id__acquired_ds__day - , subq_14.customer_id__acquired_ds__week - , subq_14.customer_id__acquired_ds__month - , subq_14.customer_id__acquired_ds__quarter - , subq_14.customer_id__acquired_ds__year - , subq_14.customer_id__acquired_ds__extract_year - , subq_14.customer_id__acquired_ds__extract_quarter - , subq_14.customer_id__acquired_ds__extract_month - , subq_14.customer_id__acquired_ds__extract_day - , subq_14.customer_id__acquired_ds__extract_dow - , subq_14.customer_id__acquired_ds__extract_doy - , subq_14.customer_third_hop_id__acquired_ds__day - , subq_14.customer_third_hop_id__acquired_ds__week - , subq_14.customer_third_hop_id__acquired_ds__month - , subq_14.customer_third_hop_id__acquired_ds__quarter - , subq_14.customer_third_hop_id__acquired_ds__year - , subq_14.customer_third_hop_id__acquired_ds__extract_year - , subq_14.customer_third_hop_id__acquired_ds__extract_quarter - , subq_14.customer_third_hop_id__acquired_ds__extract_month - , subq_14.customer_third_hop_id__acquired_ds__extract_day - , subq_14.customer_third_hop_id__acquired_ds__extract_dow - , subq_14.customer_third_hop_id__acquired_ds__extract_doy - , subq_14.acquired_ds__day AS metric_time__day - , subq_14.acquired_ds__week AS metric_time__week - , subq_14.acquired_ds__month AS metric_time__month - , subq_14.acquired_ds__quarter AS metric_time__quarter - , subq_14.acquired_ds__year AS metric_time__year - , subq_14.acquired_ds__extract_year AS metric_time__extract_year - , subq_14.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_14.acquired_ds__extract_month AS metric_time__extract_month - , subq_14.acquired_ds__extract_day AS metric_time__extract_day - , subq_14.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_14.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_14.customer_id - , subq_14.customer_third_hop_id - , subq_14.customer_id__customer_third_hop_id - , subq_14.customer_third_hop_id__customer_id - , subq_14.country - , subq_14.customer_id__country - , subq_14.customer_third_hop_id__country - , subq_14.customers_with_other_data + subq_12.acquired_ds__day + , subq_12.acquired_ds__week + , subq_12.acquired_ds__month + , subq_12.acquired_ds__quarter + , subq_12.acquired_ds__year + , subq_12.acquired_ds__extract_year + , subq_12.acquired_ds__extract_quarter + , subq_12.acquired_ds__extract_month + , subq_12.acquired_ds__extract_day + , subq_12.acquired_ds__extract_dow + , subq_12.acquired_ds__extract_doy + , subq_12.customer_id__acquired_ds__day + , subq_12.customer_id__acquired_ds__week + , subq_12.customer_id__acquired_ds__month + , subq_12.customer_id__acquired_ds__quarter + , subq_12.customer_id__acquired_ds__year + , subq_12.customer_id__acquired_ds__extract_year + , subq_12.customer_id__acquired_ds__extract_quarter + , subq_12.customer_id__acquired_ds__extract_month + , subq_12.customer_id__acquired_ds__extract_day + , subq_12.customer_id__acquired_ds__extract_dow + , subq_12.customer_id__acquired_ds__extract_doy + , subq_12.customer_third_hop_id__acquired_ds__day + , subq_12.customer_third_hop_id__acquired_ds__week + , subq_12.customer_third_hop_id__acquired_ds__month + , subq_12.customer_third_hop_id__acquired_ds__quarter + , subq_12.customer_third_hop_id__acquired_ds__year + , subq_12.customer_third_hop_id__acquired_ds__extract_year + , subq_12.customer_third_hop_id__acquired_ds__extract_quarter + , subq_12.customer_third_hop_id__acquired_ds__extract_month + , subq_12.customer_third_hop_id__acquired_ds__extract_day + , subq_12.customer_third_hop_id__acquired_ds__extract_dow + , subq_12.customer_third_hop_id__acquired_ds__extract_doy + , subq_12.acquired_ds__day AS metric_time__day + , subq_12.acquired_ds__week AS metric_time__week + , subq_12.acquired_ds__month AS metric_time__month + , subq_12.acquired_ds__quarter AS metric_time__quarter + , subq_12.acquired_ds__year AS metric_time__year + , subq_12.acquired_ds__extract_year AS metric_time__extract_year + , subq_12.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_12.acquired_ds__extract_month AS metric_time__extract_month + , subq_12.acquired_ds__extract_day AS metric_time__extract_day + , subq_12.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_12.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_12.customer_id + , subq_12.customer_third_hop_id + , subq_12.customer_id__customer_third_hop_id + , subq_12.customer_third_hop_id__customer_id + , subq_12.country + , subq_12.customer_id__country + , subq_12.customer_third_hop_id__country + , subq_12.customers_with_other_data FROM ( -- Read Elements From Semantic Model 'customer_other_data' SELECT @@ -291,24 +291,24 @@ FROM ( , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_14 - ) subq_15 + ) subq_12 + ) subq_13 WHERE customer_id__country = 'paraguay' - ) subq_16 - ) subq_17 + ) subq_14 + ) subq_15 WHERE customer_id__country = 'paraguay' - ) subq_18 - ) subq_19 + ) subq_16 + ) subq_17 GROUP BY - subq_19.customer_id__customer_third_hop_id - ) subq_20 - ) subq_21 - ) subq_22 + subq_17.customer_id__customer_third_hop_id + ) subq_18 + ) subq_19 + ) subq_20 ON - subq_13.customer_third_hop_id = subq_22.customer_id__customer_third_hop_id - ) subq_23 - ) subq_24 + subq_11.customer_third_hop_id = subq_20.customer_id__customer_third_hop_id + ) subq_21 + ) subq_22 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_23 + ) subq_24 +) subq_25 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/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 7c12d6cf98..4af49531fb 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_39.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_37.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -35,14 +35,14 @@ FROM ( , country AS customer_id__country , 1 AS customers_with_other_data FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_32 + ) subq_30 WHERE customer_id__country = 'paraguay' - ) subq_34 + ) subq_32 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_39 + ) subq_37 ON - third_hop_table_src_22000.customer_third_hop_id = subq_39.customer_id__customer_third_hop_id -) subq_41 + third_hop_table_src_22000.customer_third_hop_id = subq_37.customer_id__customer_third_hop_id +) subq_39 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_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 7b23ae782a..5938f67a2e 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_27.third_hop_count + subq_25.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_26.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_24.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_25.third_hop_count + subq_23.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_24.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_24.third_hop_count + subq_22.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_22.third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_23.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_23.third_hop_count + subq_21.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_21.third_hop_count FROM ( -- Join Standard Outputs SELECT - subq_13.customer_third_hop_id AS customer_third_hop_id - , subq_22.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id - , subq_22.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_13.third_hop_count AS third_hop_count + subq_11.customer_third_hop_id AS customer_third_hop_id + , subq_20.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_20.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_11.third_hop_count AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] SELECT - subq_12.customer_third_hop_id - , subq_12.third_hop_count + subq_10.customer_third_hop_id + , subq_10.third_hop_count FROM ( -- Metric Time Dimension 'third_hop_ds' SELECT - subq_11.third_hop_ds__day - , subq_11.third_hop_ds__week - , subq_11.third_hop_ds__month - , subq_11.third_hop_ds__quarter - , subq_11.third_hop_ds__year - , subq_11.third_hop_ds__extract_year - , subq_11.third_hop_ds__extract_quarter - , subq_11.third_hop_ds__extract_month - , subq_11.third_hop_ds__extract_day - , subq_11.third_hop_ds__extract_dow - , subq_11.third_hop_ds__extract_doy - , subq_11.customer_third_hop_id__third_hop_ds__day - , subq_11.customer_third_hop_id__third_hop_ds__week - , subq_11.customer_third_hop_id__third_hop_ds__month - , subq_11.customer_third_hop_id__third_hop_ds__quarter - , subq_11.customer_third_hop_id__third_hop_ds__year - , subq_11.customer_third_hop_id__third_hop_ds__extract_year - , subq_11.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_11.customer_third_hop_id__third_hop_ds__extract_month - , subq_11.customer_third_hop_id__third_hop_ds__extract_day - , subq_11.customer_third_hop_id__third_hop_ds__extract_dow - , subq_11.customer_third_hop_id__third_hop_ds__extract_doy - , subq_11.third_hop_ds__day AS metric_time__day - , subq_11.third_hop_ds__week AS metric_time__week - , subq_11.third_hop_ds__month AS metric_time__month - , subq_11.third_hop_ds__quarter AS metric_time__quarter - , subq_11.third_hop_ds__year AS metric_time__year - , subq_11.third_hop_ds__extract_year AS metric_time__extract_year - , subq_11.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_11.third_hop_ds__extract_month AS metric_time__extract_month - , subq_11.third_hop_ds__extract_day AS metric_time__extract_day - , subq_11.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_11.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_11.customer_third_hop_id - , subq_11.value - , subq_11.customer_third_hop_id__value - , subq_11.third_hop_count + subq_9.third_hop_ds__day + , subq_9.third_hop_ds__week + , subq_9.third_hop_ds__month + , subq_9.third_hop_ds__quarter + , subq_9.third_hop_ds__year + , subq_9.third_hop_ds__extract_year + , subq_9.third_hop_ds__extract_quarter + , subq_9.third_hop_ds__extract_month + , subq_9.third_hop_ds__extract_day + , subq_9.third_hop_ds__extract_dow + , subq_9.third_hop_ds__extract_doy + , subq_9.customer_third_hop_id__third_hop_ds__day + , subq_9.customer_third_hop_id__third_hop_ds__week + , subq_9.customer_third_hop_id__third_hop_ds__month + , subq_9.customer_third_hop_id__third_hop_ds__quarter + , subq_9.customer_third_hop_id__third_hop_ds__year + , subq_9.customer_third_hop_id__third_hop_ds__extract_year + , subq_9.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_9.customer_third_hop_id__third_hop_ds__extract_month + , subq_9.customer_third_hop_id__third_hop_ds__extract_day + , subq_9.customer_third_hop_id__third_hop_ds__extract_dow + , subq_9.customer_third_hop_id__third_hop_ds__extract_doy + , subq_9.third_hop_ds__day AS metric_time__day + , subq_9.third_hop_ds__week AS metric_time__week + , subq_9.third_hop_ds__month AS metric_time__month + , subq_9.third_hop_ds__quarter AS metric_time__quarter + , subq_9.third_hop_ds__year AS metric_time__year + , subq_9.third_hop_ds__extract_year AS metric_time__extract_year + , subq_9.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_9.third_hop_ds__extract_month AS metric_time__extract_month + , subq_9.third_hop_ds__extract_day AS metric_time__extract_day + , subq_9.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_9.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_9.customer_third_hop_id + , subq_9.value + , subq_9.customer_third_hop_id__value + , subq_9.third_hop_count FROM ( -- Read Elements From Semantic Model 'third_hop_table' SELECT @@ -101,151 +101,151 @@ FROM ( , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy , third_hop_table_src_22000.customer_third_hop_id FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_11 - ) subq_12 - ) subq_13 + ) subq_9 + ) subq_10 + ) subq_11 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_21.customer_id__customer_third_hop_id - , subq_21.customer_id__customer_third_hop_id__paraguayan_customers + subq_19.customer_id__customer_third_hop_id + , subq_19.customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Compute Metrics via Expressions SELECT - subq_20.customer_id__customer_third_hop_id - , subq_20.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_18.customer_id__customer_third_hop_id + , subq_18.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( -- Aggregate Measures SELECT - subq_19.customer_id__customer_third_hop_id - , SUM(subq_19.customers_with_other_data) AS customers_with_other_data + subq_17.customer_id__customer_third_hop_id + , SUM(subq_17.customers_with_other_data) AS customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] SELECT - subq_18.customer_id__customer_third_hop_id - , subq_18.customers_with_other_data + subq_16.customer_id__customer_third_hop_id + , subq_16.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_17.customer_id__customer_third_hop_id - , subq_17.customer_id__country - , subq_17.customers_with_other_data + subq_15.customer_id__customer_third_hop_id + , subq_15.customer_id__country + , subq_15.customers_with_other_data FROM ( -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT - subq_16.customer_id__customer_third_hop_id - , subq_16.customer_id__country - , subq_16.customers_with_other_data + subq_14.customer_id__customer_third_hop_id + , subq_14.customer_id__country + , subq_14.customers_with_other_data FROM ( -- Constrain Output with WHERE SELECT - subq_15.acquired_ds__day - , subq_15.acquired_ds__week - , subq_15.acquired_ds__month - , subq_15.acquired_ds__quarter - , subq_15.acquired_ds__year - , subq_15.acquired_ds__extract_year - , subq_15.acquired_ds__extract_quarter - , subq_15.acquired_ds__extract_month - , subq_15.acquired_ds__extract_day - , subq_15.acquired_ds__extract_dow - , subq_15.acquired_ds__extract_doy - , subq_15.customer_id__acquired_ds__day - , subq_15.customer_id__acquired_ds__week - , subq_15.customer_id__acquired_ds__month - , subq_15.customer_id__acquired_ds__quarter - , subq_15.customer_id__acquired_ds__year - , subq_15.customer_id__acquired_ds__extract_year - , subq_15.customer_id__acquired_ds__extract_quarter - , subq_15.customer_id__acquired_ds__extract_month - , subq_15.customer_id__acquired_ds__extract_day - , subq_15.customer_id__acquired_ds__extract_dow - , subq_15.customer_id__acquired_ds__extract_doy - , subq_15.customer_third_hop_id__acquired_ds__day - , subq_15.customer_third_hop_id__acquired_ds__week - , subq_15.customer_third_hop_id__acquired_ds__month - , subq_15.customer_third_hop_id__acquired_ds__quarter - , subq_15.customer_third_hop_id__acquired_ds__year - , subq_15.customer_third_hop_id__acquired_ds__extract_year - , subq_15.customer_third_hop_id__acquired_ds__extract_quarter - , subq_15.customer_third_hop_id__acquired_ds__extract_month - , subq_15.customer_third_hop_id__acquired_ds__extract_day - , subq_15.customer_third_hop_id__acquired_ds__extract_dow - , subq_15.customer_third_hop_id__acquired_ds__extract_doy - , subq_15.metric_time__day - , subq_15.metric_time__week - , subq_15.metric_time__month - , subq_15.metric_time__quarter - , subq_15.metric_time__year - , subq_15.metric_time__extract_year - , subq_15.metric_time__extract_quarter - , subq_15.metric_time__extract_month - , subq_15.metric_time__extract_day - , subq_15.metric_time__extract_dow - , subq_15.metric_time__extract_doy - , subq_15.customer_id - , subq_15.customer_third_hop_id - , subq_15.customer_id__customer_third_hop_id - , subq_15.customer_third_hop_id__customer_id - , subq_15.country - , subq_15.customer_id__country - , subq_15.customer_third_hop_id__country - , subq_15.customers_with_other_data + subq_13.acquired_ds__day + , subq_13.acquired_ds__week + , subq_13.acquired_ds__month + , subq_13.acquired_ds__quarter + , subq_13.acquired_ds__year + , subq_13.acquired_ds__extract_year + , subq_13.acquired_ds__extract_quarter + , subq_13.acquired_ds__extract_month + , subq_13.acquired_ds__extract_day + , subq_13.acquired_ds__extract_dow + , subq_13.acquired_ds__extract_doy + , subq_13.customer_id__acquired_ds__day + , subq_13.customer_id__acquired_ds__week + , subq_13.customer_id__acquired_ds__month + , subq_13.customer_id__acquired_ds__quarter + , subq_13.customer_id__acquired_ds__year + , subq_13.customer_id__acquired_ds__extract_year + , subq_13.customer_id__acquired_ds__extract_quarter + , subq_13.customer_id__acquired_ds__extract_month + , subq_13.customer_id__acquired_ds__extract_day + , subq_13.customer_id__acquired_ds__extract_dow + , subq_13.customer_id__acquired_ds__extract_doy + , subq_13.customer_third_hop_id__acquired_ds__day + , subq_13.customer_third_hop_id__acquired_ds__week + , subq_13.customer_third_hop_id__acquired_ds__month + , subq_13.customer_third_hop_id__acquired_ds__quarter + , subq_13.customer_third_hop_id__acquired_ds__year + , subq_13.customer_third_hop_id__acquired_ds__extract_year + , subq_13.customer_third_hop_id__acquired_ds__extract_quarter + , subq_13.customer_third_hop_id__acquired_ds__extract_month + , subq_13.customer_third_hop_id__acquired_ds__extract_day + , subq_13.customer_third_hop_id__acquired_ds__extract_dow + , subq_13.customer_third_hop_id__acquired_ds__extract_doy + , subq_13.metric_time__day + , subq_13.metric_time__week + , subq_13.metric_time__month + , subq_13.metric_time__quarter + , subq_13.metric_time__year + , subq_13.metric_time__extract_year + , subq_13.metric_time__extract_quarter + , subq_13.metric_time__extract_month + , subq_13.metric_time__extract_day + , subq_13.metric_time__extract_dow + , subq_13.metric_time__extract_doy + , subq_13.customer_id + , subq_13.customer_third_hop_id + , subq_13.customer_id__customer_third_hop_id + , subq_13.customer_third_hop_id__customer_id + , subq_13.country + , subq_13.customer_id__country + , subq_13.customer_third_hop_id__country + , subq_13.customers_with_other_data FROM ( -- Metric Time Dimension 'acquired_ds' SELECT - subq_14.acquired_ds__day - , subq_14.acquired_ds__week - , subq_14.acquired_ds__month - , subq_14.acquired_ds__quarter - , subq_14.acquired_ds__year - , subq_14.acquired_ds__extract_year - , subq_14.acquired_ds__extract_quarter - , subq_14.acquired_ds__extract_month - , subq_14.acquired_ds__extract_day - , subq_14.acquired_ds__extract_dow - , subq_14.acquired_ds__extract_doy - , subq_14.customer_id__acquired_ds__day - , subq_14.customer_id__acquired_ds__week - , subq_14.customer_id__acquired_ds__month - , subq_14.customer_id__acquired_ds__quarter - , subq_14.customer_id__acquired_ds__year - , subq_14.customer_id__acquired_ds__extract_year - , subq_14.customer_id__acquired_ds__extract_quarter - , subq_14.customer_id__acquired_ds__extract_month - , subq_14.customer_id__acquired_ds__extract_day - , subq_14.customer_id__acquired_ds__extract_dow - , subq_14.customer_id__acquired_ds__extract_doy - , subq_14.customer_third_hop_id__acquired_ds__day - , subq_14.customer_third_hop_id__acquired_ds__week - , subq_14.customer_third_hop_id__acquired_ds__month - , subq_14.customer_third_hop_id__acquired_ds__quarter - , subq_14.customer_third_hop_id__acquired_ds__year - , subq_14.customer_third_hop_id__acquired_ds__extract_year - , subq_14.customer_third_hop_id__acquired_ds__extract_quarter - , subq_14.customer_third_hop_id__acquired_ds__extract_month - , subq_14.customer_third_hop_id__acquired_ds__extract_day - , subq_14.customer_third_hop_id__acquired_ds__extract_dow - , subq_14.customer_third_hop_id__acquired_ds__extract_doy - , subq_14.acquired_ds__day AS metric_time__day - , subq_14.acquired_ds__week AS metric_time__week - , subq_14.acquired_ds__month AS metric_time__month - , subq_14.acquired_ds__quarter AS metric_time__quarter - , subq_14.acquired_ds__year AS metric_time__year - , subq_14.acquired_ds__extract_year AS metric_time__extract_year - , subq_14.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_14.acquired_ds__extract_month AS metric_time__extract_month - , subq_14.acquired_ds__extract_day AS metric_time__extract_day - , subq_14.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_14.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_14.customer_id - , subq_14.customer_third_hop_id - , subq_14.customer_id__customer_third_hop_id - , subq_14.customer_third_hop_id__customer_id - , subq_14.country - , subq_14.customer_id__country - , subq_14.customer_third_hop_id__country - , subq_14.customers_with_other_data + subq_12.acquired_ds__day + , subq_12.acquired_ds__week + , subq_12.acquired_ds__month + , subq_12.acquired_ds__quarter + , subq_12.acquired_ds__year + , subq_12.acquired_ds__extract_year + , subq_12.acquired_ds__extract_quarter + , subq_12.acquired_ds__extract_month + , subq_12.acquired_ds__extract_day + , subq_12.acquired_ds__extract_dow + , subq_12.acquired_ds__extract_doy + , subq_12.customer_id__acquired_ds__day + , subq_12.customer_id__acquired_ds__week + , subq_12.customer_id__acquired_ds__month + , subq_12.customer_id__acquired_ds__quarter + , subq_12.customer_id__acquired_ds__year + , subq_12.customer_id__acquired_ds__extract_year + , subq_12.customer_id__acquired_ds__extract_quarter + , subq_12.customer_id__acquired_ds__extract_month + , subq_12.customer_id__acquired_ds__extract_day + , subq_12.customer_id__acquired_ds__extract_dow + , subq_12.customer_id__acquired_ds__extract_doy + , subq_12.customer_third_hop_id__acquired_ds__day + , subq_12.customer_third_hop_id__acquired_ds__week + , subq_12.customer_third_hop_id__acquired_ds__month + , subq_12.customer_third_hop_id__acquired_ds__quarter + , subq_12.customer_third_hop_id__acquired_ds__year + , subq_12.customer_third_hop_id__acquired_ds__extract_year + , subq_12.customer_third_hop_id__acquired_ds__extract_quarter + , subq_12.customer_third_hop_id__acquired_ds__extract_month + , subq_12.customer_third_hop_id__acquired_ds__extract_day + , subq_12.customer_third_hop_id__acquired_ds__extract_dow + , subq_12.customer_third_hop_id__acquired_ds__extract_doy + , subq_12.acquired_ds__day AS metric_time__day + , subq_12.acquired_ds__week AS metric_time__week + , subq_12.acquired_ds__month AS metric_time__month + , subq_12.acquired_ds__quarter AS metric_time__quarter + , subq_12.acquired_ds__year AS metric_time__year + , subq_12.acquired_ds__extract_year AS metric_time__extract_year + , subq_12.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_12.acquired_ds__extract_month AS metric_time__extract_month + , subq_12.acquired_ds__extract_day AS metric_time__extract_day + , subq_12.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_12.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_12.customer_id + , subq_12.customer_third_hop_id + , subq_12.customer_id__customer_third_hop_id + , subq_12.customer_third_hop_id__customer_id + , subq_12.country + , subq_12.customer_id__country + , subq_12.customer_third_hop_id__country + , subq_12.customers_with_other_data FROM ( -- Read Elements From Semantic Model 'customer_other_data' SELECT @@ -291,24 +291,24 @@ FROM ( , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_14 - ) subq_15 + ) subq_12 + ) subq_13 WHERE customer_id__country = 'paraguay' - ) subq_16 - ) subq_17 + ) subq_14 + ) subq_15 WHERE customer_id__country = 'paraguay' - ) subq_18 - ) subq_19 + ) subq_16 + ) subq_17 GROUP BY - subq_19.customer_id__customer_third_hop_id - ) subq_20 - ) subq_21 - ) subq_22 + subq_17.customer_id__customer_third_hop_id + ) subq_18 + ) subq_19 + ) subq_20 ON - subq_13.customer_third_hop_id = subq_22.customer_id__customer_third_hop_id - ) subq_23 - ) subq_24 + subq_11.customer_third_hop_id = subq_20.customer_id__customer_third_hop_id + ) subq_21 + ) subq_22 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_25 - ) subq_26 -) subq_27 + ) subq_23 + ) subq_24 +) subq_25 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/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 7c12d6cf98..4af49531fb 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_39.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_37.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -35,14 +35,14 @@ FROM ( , country AS customer_id__country , 1 AS customers_with_other_data FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_32 + ) subq_30 WHERE customer_id__country = 'paraguay' - ) subq_34 + ) subq_32 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_39 + ) subq_37 ON - third_hop_table_src_22000.customer_third_hop_id = subq_39.customer_id__customer_third_hop_id -) subq_41 + third_hop_table_src_22000.customer_third_hop_id = subq_37.customer_id__customer_third_hop_id +) subq_39 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_dimensions_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_dimensions_with_time_constraint__plan0.sql index 928c4ff35d..77f6cbda46 100644 --- a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_dimensions_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/BigQuery/test_dimensions_with_time_constraint__plan0.sql @@ -1,130 +1,130 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.listing__is_lux_latest - , subq_9.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-03T00:00:00] SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.created_at__day - , subq_8.created_at__week - , subq_8.created_at__month - , subq_8.created_at__quarter - , subq_8.created_at__year - , subq_8.created_at__extract_year - , subq_8.created_at__extract_quarter - , subq_8.created_at__extract_month - , subq_8.created_at__extract_day - , subq_8.created_at__extract_dow - , subq_8.created_at__extract_doy - , subq_8.listing__ds__day - , subq_8.listing__ds__week - , subq_8.listing__ds__month - , subq_8.listing__ds__quarter - , subq_8.listing__ds__year - , subq_8.listing__ds__extract_year - , subq_8.listing__ds__extract_quarter - , subq_8.listing__ds__extract_month - , subq_8.listing__ds__extract_day - , subq_8.listing__ds__extract_dow - , subq_8.listing__ds__extract_doy - , subq_8.listing__created_at__day - , subq_8.listing__created_at__week - , subq_8.listing__created_at__month - , subq_8.listing__created_at__quarter - , subq_8.listing__created_at__year - , subq_8.listing__created_at__extract_year - , subq_8.listing__created_at__extract_quarter - , subq_8.listing__created_at__extract_month - , subq_8.listing__created_at__extract_day - , subq_8.listing__created_at__extract_dow - , subq_8.listing__created_at__extract_doy - , subq_8.metric_time__day - , subq_8.listing - , subq_8.user - , subq_8.listing__user - , subq_8.country_latest - , subq_8.is_lux_latest - , subq_8.capacity_latest - , subq_8.listing__country_latest - , subq_8.listing__is_lux_latest - , subq_8.listing__capacity_latest - , subq_8.user__home_state_latest - , subq_8.listings - , subq_8.largest_listing - , subq_8.smallest_listing + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.created_at__day + , subq_6.created_at__week + , subq_6.created_at__month + , subq_6.created_at__quarter + , subq_6.created_at__year + , subq_6.created_at__extract_year + , subq_6.created_at__extract_quarter + , subq_6.created_at__extract_month + , subq_6.created_at__extract_day + , subq_6.created_at__extract_dow + , subq_6.created_at__extract_doy + , subq_6.listing__ds__day + , subq_6.listing__ds__week + , subq_6.listing__ds__month + , subq_6.listing__ds__quarter + , subq_6.listing__ds__year + , subq_6.listing__ds__extract_year + , subq_6.listing__ds__extract_quarter + , subq_6.listing__ds__extract_month + , subq_6.listing__ds__extract_day + , subq_6.listing__ds__extract_dow + , subq_6.listing__ds__extract_doy + , subq_6.listing__created_at__day + , subq_6.listing__created_at__week + , subq_6.listing__created_at__month + , subq_6.listing__created_at__quarter + , subq_6.listing__created_at__year + , subq_6.listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month + , subq_6.listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy + , subq_6.metric_time__day + , subq_6.listing + , subq_6.user + , subq_6.listing__user + , subq_6.country_latest + , subq_6.is_lux_latest + , subq_6.capacity_latest + , subq_6.listing__country_latest + , subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.user__home_state_latest + , subq_6.listings + , subq_6.largest_listing + , subq_6.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.created_at__day AS created_at__day - , subq_2.created_at__week AS created_at__week - , subq_2.created_at__month AS created_at__month - , subq_2.created_at__quarter AS created_at__quarter - , subq_2.created_at__year AS created_at__year - , subq_2.created_at__extract_year AS created_at__extract_year - , subq_2.created_at__extract_quarter AS created_at__extract_quarter - , subq_2.created_at__extract_month AS created_at__extract_month - , subq_2.created_at__extract_day AS created_at__extract_day - , subq_2.created_at__extract_dow AS created_at__extract_dow - , subq_2.created_at__extract_doy AS created_at__extract_doy - , subq_2.listing__ds__day AS listing__ds__day - , subq_2.listing__ds__week AS listing__ds__week - , subq_2.listing__ds__month AS listing__ds__month - , subq_2.listing__ds__quarter AS listing__ds__quarter - , subq_2.listing__ds__year AS listing__ds__year - , subq_2.listing__ds__extract_year AS listing__ds__extract_year - , subq_2.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_2.listing__ds__extract_month AS listing__ds__extract_month - , subq_2.listing__ds__extract_day AS listing__ds__extract_day - , subq_2.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_2.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_2.listing__created_at__day AS listing__created_at__day - , subq_2.listing__created_at__week AS listing__created_at__week - , subq_2.listing__created_at__month AS listing__created_at__month - , subq_2.listing__created_at__quarter AS listing__created_at__quarter - , subq_2.listing__created_at__year AS listing__created_at__year - , subq_2.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_2.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_5.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.user AS user - , subq_2.listing__user AS listing__user - , subq_2.country_latest AS country_latest - , subq_2.is_lux_latest AS is_lux_latest - , subq_2.capacity_latest AS capacity_latest - , subq_2.listing__country_latest AS listing__country_latest - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_7.home_state_latest AS user__home_state_latest - , subq_2.listings AS listings - , subq_2.largest_listing AS largest_listing - , subq_2.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_5.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -185,36 +185,36 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 + ) subq_0 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_4.metric_time__day + subq_2.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds__day AS metric_time__day + , subq_1.ds__week AS metric_time__week + , subq_1.ds__month AS metric_time__month + , subq_1.ds__quarter AS metric_time__quarter + , subq_1.ds__year AS metric_time__year + , subq_1.ds__extract_year AS metric_time__extract_year + , subq_1.ds__extract_quarter AS metric_time__extract_quarter + , subq_1.ds__extract_month AS metric_time__extract_month + , subq_1.ds__extract_day AS metric_time__extract_day + , subq_1.ds__extract_dow AS metric_time__extract_dow + , subq_1.ds__extract_doy AS metric_time__extract_doy FROM ( -- Time Spine SELECT @@ -230,14 +230,14 @@ FROM ( , IF(EXTRACT(dayofweek FROM time_spine_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM time_spine_src_28000.ds) - 1) AS ds__extract_dow , EXTRACT(dayofyear FROM time_spine_src_28000.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_1 + ) subq_2 + ) subq_3 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_6.user - , subq_6.home_state_latest + subq_4.user + , subq_4.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -267,13 +267,13 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 ON - subq_2.user = subq_7.user - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' -) subq_9 + subq_0.user = subq_5.user + ) subq_6 + WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' +) subq_7 GROUP BY metric_time__day , listing__is_lux_latest diff --git a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_dimensions_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_dimensions_with_time_constraint__plan0.sql index 7b375398ef..c158a74935 100644 --- a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_dimensions_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Databricks/test_dimensions_with_time_constraint__plan0.sql @@ -1,130 +1,130 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.listing__is_lux_latest - , subq_9.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-03T00:00:00] SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.created_at__day - , subq_8.created_at__week - , subq_8.created_at__month - , subq_8.created_at__quarter - , subq_8.created_at__year - , subq_8.created_at__extract_year - , subq_8.created_at__extract_quarter - , subq_8.created_at__extract_month - , subq_8.created_at__extract_day - , subq_8.created_at__extract_dow - , subq_8.created_at__extract_doy - , subq_8.listing__ds__day - , subq_8.listing__ds__week - , subq_8.listing__ds__month - , subq_8.listing__ds__quarter - , subq_8.listing__ds__year - , subq_8.listing__ds__extract_year - , subq_8.listing__ds__extract_quarter - , subq_8.listing__ds__extract_month - , subq_8.listing__ds__extract_day - , subq_8.listing__ds__extract_dow - , subq_8.listing__ds__extract_doy - , subq_8.listing__created_at__day - , subq_8.listing__created_at__week - , subq_8.listing__created_at__month - , subq_8.listing__created_at__quarter - , subq_8.listing__created_at__year - , subq_8.listing__created_at__extract_year - , subq_8.listing__created_at__extract_quarter - , subq_8.listing__created_at__extract_month - , subq_8.listing__created_at__extract_day - , subq_8.listing__created_at__extract_dow - , subq_8.listing__created_at__extract_doy - , subq_8.metric_time__day - , subq_8.listing - , subq_8.user - , subq_8.listing__user - , subq_8.country_latest - , subq_8.is_lux_latest - , subq_8.capacity_latest - , subq_8.listing__country_latest - , subq_8.listing__is_lux_latest - , subq_8.listing__capacity_latest - , subq_8.user__home_state_latest - , subq_8.listings - , subq_8.largest_listing - , subq_8.smallest_listing + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.created_at__day + , subq_6.created_at__week + , subq_6.created_at__month + , subq_6.created_at__quarter + , subq_6.created_at__year + , subq_6.created_at__extract_year + , subq_6.created_at__extract_quarter + , subq_6.created_at__extract_month + , subq_6.created_at__extract_day + , subq_6.created_at__extract_dow + , subq_6.created_at__extract_doy + , subq_6.listing__ds__day + , subq_6.listing__ds__week + , subq_6.listing__ds__month + , subq_6.listing__ds__quarter + , subq_6.listing__ds__year + , subq_6.listing__ds__extract_year + , subq_6.listing__ds__extract_quarter + , subq_6.listing__ds__extract_month + , subq_6.listing__ds__extract_day + , subq_6.listing__ds__extract_dow + , subq_6.listing__ds__extract_doy + , subq_6.listing__created_at__day + , subq_6.listing__created_at__week + , subq_6.listing__created_at__month + , subq_6.listing__created_at__quarter + , subq_6.listing__created_at__year + , subq_6.listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month + , subq_6.listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy + , subq_6.metric_time__day + , subq_6.listing + , subq_6.user + , subq_6.listing__user + , subq_6.country_latest + , subq_6.is_lux_latest + , subq_6.capacity_latest + , subq_6.listing__country_latest + , subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.user__home_state_latest + , subq_6.listings + , subq_6.largest_listing + , subq_6.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.created_at__day AS created_at__day - , subq_2.created_at__week AS created_at__week - , subq_2.created_at__month AS created_at__month - , subq_2.created_at__quarter AS created_at__quarter - , subq_2.created_at__year AS created_at__year - , subq_2.created_at__extract_year AS created_at__extract_year - , subq_2.created_at__extract_quarter AS created_at__extract_quarter - , subq_2.created_at__extract_month AS created_at__extract_month - , subq_2.created_at__extract_day AS created_at__extract_day - , subq_2.created_at__extract_dow AS created_at__extract_dow - , subq_2.created_at__extract_doy AS created_at__extract_doy - , subq_2.listing__ds__day AS listing__ds__day - , subq_2.listing__ds__week AS listing__ds__week - , subq_2.listing__ds__month AS listing__ds__month - , subq_2.listing__ds__quarter AS listing__ds__quarter - , subq_2.listing__ds__year AS listing__ds__year - , subq_2.listing__ds__extract_year AS listing__ds__extract_year - , subq_2.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_2.listing__ds__extract_month AS listing__ds__extract_month - , subq_2.listing__ds__extract_day AS listing__ds__extract_day - , subq_2.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_2.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_2.listing__created_at__day AS listing__created_at__day - , subq_2.listing__created_at__week AS listing__created_at__week - , subq_2.listing__created_at__month AS listing__created_at__month - , subq_2.listing__created_at__quarter AS listing__created_at__quarter - , subq_2.listing__created_at__year AS listing__created_at__year - , subq_2.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_2.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_5.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.user AS user - , subq_2.listing__user AS listing__user - , subq_2.country_latest AS country_latest - , subq_2.is_lux_latest AS is_lux_latest - , subq_2.capacity_latest AS capacity_latest - , subq_2.listing__country_latest AS listing__country_latest - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_7.home_state_latest AS user__home_state_latest - , subq_2.listings AS listings - , subq_2.largest_listing AS largest_listing - , subq_2.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_5.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -185,36 +185,36 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 + ) subq_0 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_4.metric_time__day + subq_2.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds__day AS metric_time__day + , subq_1.ds__week AS metric_time__week + , subq_1.ds__month AS metric_time__month + , subq_1.ds__quarter AS metric_time__quarter + , subq_1.ds__year AS metric_time__year + , subq_1.ds__extract_year AS metric_time__extract_year + , subq_1.ds__extract_quarter AS metric_time__extract_quarter + , subq_1.ds__extract_month AS metric_time__extract_month + , subq_1.ds__extract_day AS metric_time__extract_day + , subq_1.ds__extract_dow AS metric_time__extract_dow + , subq_1.ds__extract_doy AS metric_time__extract_doy FROM ( -- Time Spine SELECT @@ -230,14 +230,14 @@ FROM ( , EXTRACT(DAYOFWEEK_ISO FROM time_spine_src_28000.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_28000.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_1 + ) subq_2 + ) subq_3 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_6.user - , subq_6.home_state_latest + subq_4.user + , subq_4.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -267,14 +267,14 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 ON - subq_2.user = subq_7.user - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' -) subq_9 + subq_0.user = subq_5.user + ) subq_6 + WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' +) subq_7 GROUP BY - subq_9.metric_time__day - , subq_9.listing__is_lux_latest - , subq_9.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_dimensions_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_dimensions_with_time_constraint__plan0.sql index df768a7cba..1e42a5d726 100644 --- a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_dimensions_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Postgres/test_dimensions_with_time_constraint__plan0.sql @@ -1,130 +1,130 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.listing__is_lux_latest - , subq_9.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-03T00:00:00] SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.created_at__day - , subq_8.created_at__week - , subq_8.created_at__month - , subq_8.created_at__quarter - , subq_8.created_at__year - , subq_8.created_at__extract_year - , subq_8.created_at__extract_quarter - , subq_8.created_at__extract_month - , subq_8.created_at__extract_day - , subq_8.created_at__extract_dow - , subq_8.created_at__extract_doy - , subq_8.listing__ds__day - , subq_8.listing__ds__week - , subq_8.listing__ds__month - , subq_8.listing__ds__quarter - , subq_8.listing__ds__year - , subq_8.listing__ds__extract_year - , subq_8.listing__ds__extract_quarter - , subq_8.listing__ds__extract_month - , subq_8.listing__ds__extract_day - , subq_8.listing__ds__extract_dow - , subq_8.listing__ds__extract_doy - , subq_8.listing__created_at__day - , subq_8.listing__created_at__week - , subq_8.listing__created_at__month - , subq_8.listing__created_at__quarter - , subq_8.listing__created_at__year - , subq_8.listing__created_at__extract_year - , subq_8.listing__created_at__extract_quarter - , subq_8.listing__created_at__extract_month - , subq_8.listing__created_at__extract_day - , subq_8.listing__created_at__extract_dow - , subq_8.listing__created_at__extract_doy - , subq_8.metric_time__day - , subq_8.listing - , subq_8.user - , subq_8.listing__user - , subq_8.country_latest - , subq_8.is_lux_latest - , subq_8.capacity_latest - , subq_8.listing__country_latest - , subq_8.listing__is_lux_latest - , subq_8.listing__capacity_latest - , subq_8.user__home_state_latest - , subq_8.listings - , subq_8.largest_listing - , subq_8.smallest_listing + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.created_at__day + , subq_6.created_at__week + , subq_6.created_at__month + , subq_6.created_at__quarter + , subq_6.created_at__year + , subq_6.created_at__extract_year + , subq_6.created_at__extract_quarter + , subq_6.created_at__extract_month + , subq_6.created_at__extract_day + , subq_6.created_at__extract_dow + , subq_6.created_at__extract_doy + , subq_6.listing__ds__day + , subq_6.listing__ds__week + , subq_6.listing__ds__month + , subq_6.listing__ds__quarter + , subq_6.listing__ds__year + , subq_6.listing__ds__extract_year + , subq_6.listing__ds__extract_quarter + , subq_6.listing__ds__extract_month + , subq_6.listing__ds__extract_day + , subq_6.listing__ds__extract_dow + , subq_6.listing__ds__extract_doy + , subq_6.listing__created_at__day + , subq_6.listing__created_at__week + , subq_6.listing__created_at__month + , subq_6.listing__created_at__quarter + , subq_6.listing__created_at__year + , subq_6.listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month + , subq_6.listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy + , subq_6.metric_time__day + , subq_6.listing + , subq_6.user + , subq_6.listing__user + , subq_6.country_latest + , subq_6.is_lux_latest + , subq_6.capacity_latest + , subq_6.listing__country_latest + , subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.user__home_state_latest + , subq_6.listings + , subq_6.largest_listing + , subq_6.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.created_at__day AS created_at__day - , subq_2.created_at__week AS created_at__week - , subq_2.created_at__month AS created_at__month - , subq_2.created_at__quarter AS created_at__quarter - , subq_2.created_at__year AS created_at__year - , subq_2.created_at__extract_year AS created_at__extract_year - , subq_2.created_at__extract_quarter AS created_at__extract_quarter - , subq_2.created_at__extract_month AS created_at__extract_month - , subq_2.created_at__extract_day AS created_at__extract_day - , subq_2.created_at__extract_dow AS created_at__extract_dow - , subq_2.created_at__extract_doy AS created_at__extract_doy - , subq_2.listing__ds__day AS listing__ds__day - , subq_2.listing__ds__week AS listing__ds__week - , subq_2.listing__ds__month AS listing__ds__month - , subq_2.listing__ds__quarter AS listing__ds__quarter - , subq_2.listing__ds__year AS listing__ds__year - , subq_2.listing__ds__extract_year AS listing__ds__extract_year - , subq_2.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_2.listing__ds__extract_month AS listing__ds__extract_month - , subq_2.listing__ds__extract_day AS listing__ds__extract_day - , subq_2.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_2.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_2.listing__created_at__day AS listing__created_at__day - , subq_2.listing__created_at__week AS listing__created_at__week - , subq_2.listing__created_at__month AS listing__created_at__month - , subq_2.listing__created_at__quarter AS listing__created_at__quarter - , subq_2.listing__created_at__year AS listing__created_at__year - , subq_2.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_2.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_5.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.user AS user - , subq_2.listing__user AS listing__user - , subq_2.country_latest AS country_latest - , subq_2.is_lux_latest AS is_lux_latest - , subq_2.capacity_latest AS capacity_latest - , subq_2.listing__country_latest AS listing__country_latest - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_7.home_state_latest AS user__home_state_latest - , subq_2.listings AS listings - , subq_2.largest_listing AS largest_listing - , subq_2.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_5.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -185,36 +185,36 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 + ) subq_0 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_4.metric_time__day + subq_2.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds__day AS metric_time__day + , subq_1.ds__week AS metric_time__week + , subq_1.ds__month AS metric_time__month + , subq_1.ds__quarter AS metric_time__quarter + , subq_1.ds__year AS metric_time__year + , subq_1.ds__extract_year AS metric_time__extract_year + , subq_1.ds__extract_quarter AS metric_time__extract_quarter + , subq_1.ds__extract_month AS metric_time__extract_month + , subq_1.ds__extract_day AS metric_time__extract_day + , subq_1.ds__extract_dow AS metric_time__extract_dow + , subq_1.ds__extract_doy AS metric_time__extract_doy FROM ( -- Time Spine SELECT @@ -230,14 +230,14 @@ FROM ( , EXTRACT(isodow FROM time_spine_src_28000.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_28000.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_1 + ) subq_2 + ) subq_3 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_6.user - , subq_6.home_state_latest + subq_4.user + , subq_4.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -267,14 +267,14 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 ON - subq_2.user = subq_7.user - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' -) subq_9 + subq_0.user = subq_5.user + ) subq_6 + WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' +) subq_7 GROUP BY - subq_9.metric_time__day - , subq_9.listing__is_lux_latest - , subq_9.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_dimensions_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_dimensions_with_time_constraint__plan0.sql index 547b977463..5d4572d904 100644 --- a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_dimensions_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Redshift/test_dimensions_with_time_constraint__plan0.sql @@ -1,130 +1,130 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.listing__is_lux_latest - , subq_9.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-03T00:00:00] SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.created_at__day - , subq_8.created_at__week - , subq_8.created_at__month - , subq_8.created_at__quarter - , subq_8.created_at__year - , subq_8.created_at__extract_year - , subq_8.created_at__extract_quarter - , subq_8.created_at__extract_month - , subq_8.created_at__extract_day - , subq_8.created_at__extract_dow - , subq_8.created_at__extract_doy - , subq_8.listing__ds__day - , subq_8.listing__ds__week - , subq_8.listing__ds__month - , subq_8.listing__ds__quarter - , subq_8.listing__ds__year - , subq_8.listing__ds__extract_year - , subq_8.listing__ds__extract_quarter - , subq_8.listing__ds__extract_month - , subq_8.listing__ds__extract_day - , subq_8.listing__ds__extract_dow - , subq_8.listing__ds__extract_doy - , subq_8.listing__created_at__day - , subq_8.listing__created_at__week - , subq_8.listing__created_at__month - , subq_8.listing__created_at__quarter - , subq_8.listing__created_at__year - , subq_8.listing__created_at__extract_year - , subq_8.listing__created_at__extract_quarter - , subq_8.listing__created_at__extract_month - , subq_8.listing__created_at__extract_day - , subq_8.listing__created_at__extract_dow - , subq_8.listing__created_at__extract_doy - , subq_8.metric_time__day - , subq_8.listing - , subq_8.user - , subq_8.listing__user - , subq_8.country_latest - , subq_8.is_lux_latest - , subq_8.capacity_latest - , subq_8.listing__country_latest - , subq_8.listing__is_lux_latest - , subq_8.listing__capacity_latest - , subq_8.user__home_state_latest - , subq_8.listings - , subq_8.largest_listing - , subq_8.smallest_listing + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.created_at__day + , subq_6.created_at__week + , subq_6.created_at__month + , subq_6.created_at__quarter + , subq_6.created_at__year + , subq_6.created_at__extract_year + , subq_6.created_at__extract_quarter + , subq_6.created_at__extract_month + , subq_6.created_at__extract_day + , subq_6.created_at__extract_dow + , subq_6.created_at__extract_doy + , subq_6.listing__ds__day + , subq_6.listing__ds__week + , subq_6.listing__ds__month + , subq_6.listing__ds__quarter + , subq_6.listing__ds__year + , subq_6.listing__ds__extract_year + , subq_6.listing__ds__extract_quarter + , subq_6.listing__ds__extract_month + , subq_6.listing__ds__extract_day + , subq_6.listing__ds__extract_dow + , subq_6.listing__ds__extract_doy + , subq_6.listing__created_at__day + , subq_6.listing__created_at__week + , subq_6.listing__created_at__month + , subq_6.listing__created_at__quarter + , subq_6.listing__created_at__year + , subq_6.listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month + , subq_6.listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy + , subq_6.metric_time__day + , subq_6.listing + , subq_6.user + , subq_6.listing__user + , subq_6.country_latest + , subq_6.is_lux_latest + , subq_6.capacity_latest + , subq_6.listing__country_latest + , subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.user__home_state_latest + , subq_6.listings + , subq_6.largest_listing + , subq_6.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.created_at__day AS created_at__day - , subq_2.created_at__week AS created_at__week - , subq_2.created_at__month AS created_at__month - , subq_2.created_at__quarter AS created_at__quarter - , subq_2.created_at__year AS created_at__year - , subq_2.created_at__extract_year AS created_at__extract_year - , subq_2.created_at__extract_quarter AS created_at__extract_quarter - , subq_2.created_at__extract_month AS created_at__extract_month - , subq_2.created_at__extract_day AS created_at__extract_day - , subq_2.created_at__extract_dow AS created_at__extract_dow - , subq_2.created_at__extract_doy AS created_at__extract_doy - , subq_2.listing__ds__day AS listing__ds__day - , subq_2.listing__ds__week AS listing__ds__week - , subq_2.listing__ds__month AS listing__ds__month - , subq_2.listing__ds__quarter AS listing__ds__quarter - , subq_2.listing__ds__year AS listing__ds__year - , subq_2.listing__ds__extract_year AS listing__ds__extract_year - , subq_2.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_2.listing__ds__extract_month AS listing__ds__extract_month - , subq_2.listing__ds__extract_day AS listing__ds__extract_day - , subq_2.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_2.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_2.listing__created_at__day AS listing__created_at__day - , subq_2.listing__created_at__week AS listing__created_at__week - , subq_2.listing__created_at__month AS listing__created_at__month - , subq_2.listing__created_at__quarter AS listing__created_at__quarter - , subq_2.listing__created_at__year AS listing__created_at__year - , subq_2.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_2.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_5.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.user AS user - , subq_2.listing__user AS listing__user - , subq_2.country_latest AS country_latest - , subq_2.is_lux_latest AS is_lux_latest - , subq_2.capacity_latest AS capacity_latest - , subq_2.listing__country_latest AS listing__country_latest - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_7.home_state_latest AS user__home_state_latest - , subq_2.listings AS listings - , subq_2.largest_listing AS largest_listing - , subq_2.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_5.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -185,36 +185,36 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 + ) subq_0 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_4.metric_time__day + subq_2.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds__day AS metric_time__day + , subq_1.ds__week AS metric_time__week + , subq_1.ds__month AS metric_time__month + , subq_1.ds__quarter AS metric_time__quarter + , subq_1.ds__year AS metric_time__year + , subq_1.ds__extract_year AS metric_time__extract_year + , subq_1.ds__extract_quarter AS metric_time__extract_quarter + , subq_1.ds__extract_month AS metric_time__extract_month + , subq_1.ds__extract_day AS metric_time__extract_day + , subq_1.ds__extract_dow AS metric_time__extract_dow + , subq_1.ds__extract_doy AS metric_time__extract_doy FROM ( -- Time Spine SELECT @@ -230,14 +230,14 @@ FROM ( , CASE WHEN EXTRACT(dow FROM time_spine_src_28000.ds) = 0 THEN EXTRACT(dow FROM time_spine_src_28000.ds) + 7 ELSE EXTRACT(dow FROM time_spine_src_28000.ds) END AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_28000.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_1 + ) subq_2 + ) subq_3 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_6.user - , subq_6.home_state_latest + subq_4.user + , subq_4.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -267,14 +267,14 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 ON - subq_2.user = subq_7.user - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' -) subq_9 + subq_0.user = subq_5.user + ) subq_6 + WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' +) subq_7 GROUP BY - subq_9.metric_time__day - , subq_9.listing__is_lux_latest - , subq_9.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_dimensions_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_dimensions_with_time_constraint__plan0.sql index 0cb9d9f2d6..98667582a9 100644 --- a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_dimensions_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Snowflake/test_dimensions_with_time_constraint__plan0.sql @@ -1,130 +1,130 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.listing__is_lux_latest - , subq_9.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-03T00:00:00] SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.created_at__day - , subq_8.created_at__week - , subq_8.created_at__month - , subq_8.created_at__quarter - , subq_8.created_at__year - , subq_8.created_at__extract_year - , subq_8.created_at__extract_quarter - , subq_8.created_at__extract_month - , subq_8.created_at__extract_day - , subq_8.created_at__extract_dow - , subq_8.created_at__extract_doy - , subq_8.listing__ds__day - , subq_8.listing__ds__week - , subq_8.listing__ds__month - , subq_8.listing__ds__quarter - , subq_8.listing__ds__year - , subq_8.listing__ds__extract_year - , subq_8.listing__ds__extract_quarter - , subq_8.listing__ds__extract_month - , subq_8.listing__ds__extract_day - , subq_8.listing__ds__extract_dow - , subq_8.listing__ds__extract_doy - , subq_8.listing__created_at__day - , subq_8.listing__created_at__week - , subq_8.listing__created_at__month - , subq_8.listing__created_at__quarter - , subq_8.listing__created_at__year - , subq_8.listing__created_at__extract_year - , subq_8.listing__created_at__extract_quarter - , subq_8.listing__created_at__extract_month - , subq_8.listing__created_at__extract_day - , subq_8.listing__created_at__extract_dow - , subq_8.listing__created_at__extract_doy - , subq_8.metric_time__day - , subq_8.listing - , subq_8.user - , subq_8.listing__user - , subq_8.country_latest - , subq_8.is_lux_latest - , subq_8.capacity_latest - , subq_8.listing__country_latest - , subq_8.listing__is_lux_latest - , subq_8.listing__capacity_latest - , subq_8.user__home_state_latest - , subq_8.listings - , subq_8.largest_listing - , subq_8.smallest_listing + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.created_at__day + , subq_6.created_at__week + , subq_6.created_at__month + , subq_6.created_at__quarter + , subq_6.created_at__year + , subq_6.created_at__extract_year + , subq_6.created_at__extract_quarter + , subq_6.created_at__extract_month + , subq_6.created_at__extract_day + , subq_6.created_at__extract_dow + , subq_6.created_at__extract_doy + , subq_6.listing__ds__day + , subq_6.listing__ds__week + , subq_6.listing__ds__month + , subq_6.listing__ds__quarter + , subq_6.listing__ds__year + , subq_6.listing__ds__extract_year + , subq_6.listing__ds__extract_quarter + , subq_6.listing__ds__extract_month + , subq_6.listing__ds__extract_day + , subq_6.listing__ds__extract_dow + , subq_6.listing__ds__extract_doy + , subq_6.listing__created_at__day + , subq_6.listing__created_at__week + , subq_6.listing__created_at__month + , subq_6.listing__created_at__quarter + , subq_6.listing__created_at__year + , subq_6.listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month + , subq_6.listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy + , subq_6.metric_time__day + , subq_6.listing + , subq_6.user + , subq_6.listing__user + , subq_6.country_latest + , subq_6.is_lux_latest + , subq_6.capacity_latest + , subq_6.listing__country_latest + , subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.user__home_state_latest + , subq_6.listings + , subq_6.largest_listing + , subq_6.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.created_at__day AS created_at__day - , subq_2.created_at__week AS created_at__week - , subq_2.created_at__month AS created_at__month - , subq_2.created_at__quarter AS created_at__quarter - , subq_2.created_at__year AS created_at__year - , subq_2.created_at__extract_year AS created_at__extract_year - , subq_2.created_at__extract_quarter AS created_at__extract_quarter - , subq_2.created_at__extract_month AS created_at__extract_month - , subq_2.created_at__extract_day AS created_at__extract_day - , subq_2.created_at__extract_dow AS created_at__extract_dow - , subq_2.created_at__extract_doy AS created_at__extract_doy - , subq_2.listing__ds__day AS listing__ds__day - , subq_2.listing__ds__week AS listing__ds__week - , subq_2.listing__ds__month AS listing__ds__month - , subq_2.listing__ds__quarter AS listing__ds__quarter - , subq_2.listing__ds__year AS listing__ds__year - , subq_2.listing__ds__extract_year AS listing__ds__extract_year - , subq_2.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_2.listing__ds__extract_month AS listing__ds__extract_month - , subq_2.listing__ds__extract_day AS listing__ds__extract_day - , subq_2.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_2.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_2.listing__created_at__day AS listing__created_at__day - , subq_2.listing__created_at__week AS listing__created_at__week - , subq_2.listing__created_at__month AS listing__created_at__month - , subq_2.listing__created_at__quarter AS listing__created_at__quarter - , subq_2.listing__created_at__year AS listing__created_at__year - , subq_2.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_2.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_5.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.user AS user - , subq_2.listing__user AS listing__user - , subq_2.country_latest AS country_latest - , subq_2.is_lux_latest AS is_lux_latest - , subq_2.capacity_latest AS capacity_latest - , subq_2.listing__country_latest AS listing__country_latest - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_7.home_state_latest AS user__home_state_latest - , subq_2.listings AS listings - , subq_2.largest_listing AS largest_listing - , subq_2.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_5.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -185,36 +185,36 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 + ) subq_0 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_4.metric_time__day + subq_2.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds__day AS metric_time__day + , subq_1.ds__week AS metric_time__week + , subq_1.ds__month AS metric_time__month + , subq_1.ds__quarter AS metric_time__quarter + , subq_1.ds__year AS metric_time__year + , subq_1.ds__extract_year AS metric_time__extract_year + , subq_1.ds__extract_quarter AS metric_time__extract_quarter + , subq_1.ds__extract_month AS metric_time__extract_month + , subq_1.ds__extract_day AS metric_time__extract_day + , subq_1.ds__extract_dow AS metric_time__extract_dow + , subq_1.ds__extract_doy AS metric_time__extract_doy FROM ( -- Time Spine SELECT @@ -230,14 +230,14 @@ FROM ( , EXTRACT(dayofweekiso FROM time_spine_src_28000.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_28000.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_1 + ) subq_2 + ) subq_3 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_6.user - , subq_6.home_state_latest + subq_4.user + , subq_4.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -267,14 +267,14 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 ON - subq_2.user = subq_7.user - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' -) subq_9 + subq_0.user = subq_5.user + ) subq_6 + WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-03' +) subq_7 GROUP BY - subq_9.metric_time__day - , subq_9.listing__is_lux_latest - , subq_9.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_dimensions_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_dimensions_with_time_constraint__plan0.sql index e5b54b564d..89ae3ebda3 100644 --- a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_dimensions_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/Trino/test_dimensions_with_time_constraint__plan0.sql @@ -1,130 +1,130 @@ -- Pass Only Elements: ['user__home_state_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_9.metric_time__day - , subq_9.listing__is_lux_latest - , subq_9.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-03T00:00:00] SELECT - subq_8.ds__day - , subq_8.ds__week - , subq_8.ds__month - , subq_8.ds__quarter - , subq_8.ds__year - , subq_8.ds__extract_year - , subq_8.ds__extract_quarter - , subq_8.ds__extract_month - , subq_8.ds__extract_day - , subq_8.ds__extract_dow - , subq_8.ds__extract_doy - , subq_8.created_at__day - , subq_8.created_at__week - , subq_8.created_at__month - , subq_8.created_at__quarter - , subq_8.created_at__year - , subq_8.created_at__extract_year - , subq_8.created_at__extract_quarter - , subq_8.created_at__extract_month - , subq_8.created_at__extract_day - , subq_8.created_at__extract_dow - , subq_8.created_at__extract_doy - , subq_8.listing__ds__day - , subq_8.listing__ds__week - , subq_8.listing__ds__month - , subq_8.listing__ds__quarter - , subq_8.listing__ds__year - , subq_8.listing__ds__extract_year - , subq_8.listing__ds__extract_quarter - , subq_8.listing__ds__extract_month - , subq_8.listing__ds__extract_day - , subq_8.listing__ds__extract_dow - , subq_8.listing__ds__extract_doy - , subq_8.listing__created_at__day - , subq_8.listing__created_at__week - , subq_8.listing__created_at__month - , subq_8.listing__created_at__quarter - , subq_8.listing__created_at__year - , subq_8.listing__created_at__extract_year - , subq_8.listing__created_at__extract_quarter - , subq_8.listing__created_at__extract_month - , subq_8.listing__created_at__extract_day - , subq_8.listing__created_at__extract_dow - , subq_8.listing__created_at__extract_doy - , subq_8.metric_time__day - , subq_8.listing - , subq_8.user - , subq_8.listing__user - , subq_8.country_latest - , subq_8.is_lux_latest - , subq_8.capacity_latest - , subq_8.listing__country_latest - , subq_8.listing__is_lux_latest - , subq_8.listing__capacity_latest - , subq_8.user__home_state_latest - , subq_8.listings - , subq_8.largest_listing - , subq_8.smallest_listing + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.created_at__day + , subq_6.created_at__week + , subq_6.created_at__month + , subq_6.created_at__quarter + , subq_6.created_at__year + , subq_6.created_at__extract_year + , subq_6.created_at__extract_quarter + , subq_6.created_at__extract_month + , subq_6.created_at__extract_day + , subq_6.created_at__extract_dow + , subq_6.created_at__extract_doy + , subq_6.listing__ds__day + , subq_6.listing__ds__week + , subq_6.listing__ds__month + , subq_6.listing__ds__quarter + , subq_6.listing__ds__year + , subq_6.listing__ds__extract_year + , subq_6.listing__ds__extract_quarter + , subq_6.listing__ds__extract_month + , subq_6.listing__ds__extract_day + , subq_6.listing__ds__extract_dow + , subq_6.listing__ds__extract_doy + , subq_6.listing__created_at__day + , subq_6.listing__created_at__week + , subq_6.listing__created_at__month + , subq_6.listing__created_at__quarter + , subq_6.listing__created_at__year + , subq_6.listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month + , subq_6.listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy + , subq_6.metric_time__day + , subq_6.listing + , subq_6.user + , subq_6.listing__user + , subq_6.country_latest + , subq_6.is_lux_latest + , subq_6.capacity_latest + , subq_6.listing__country_latest + , subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.user__home_state_latest + , subq_6.listings + , subq_6.largest_listing + , subq_6.smallest_listing FROM ( -- Join Standard Outputs SELECT - subq_2.ds__day AS ds__day - , subq_2.ds__week AS ds__week - , subq_2.ds__month AS ds__month - , subq_2.ds__quarter AS ds__quarter - , subq_2.ds__year AS ds__year - , subq_2.ds__extract_year AS ds__extract_year - , subq_2.ds__extract_quarter AS ds__extract_quarter - , subq_2.ds__extract_month AS ds__extract_month - , subq_2.ds__extract_day AS ds__extract_day - , subq_2.ds__extract_dow AS ds__extract_dow - , subq_2.ds__extract_doy AS ds__extract_doy - , subq_2.created_at__day AS created_at__day - , subq_2.created_at__week AS created_at__week - , subq_2.created_at__month AS created_at__month - , subq_2.created_at__quarter AS created_at__quarter - , subq_2.created_at__year AS created_at__year - , subq_2.created_at__extract_year AS created_at__extract_year - , subq_2.created_at__extract_quarter AS created_at__extract_quarter - , subq_2.created_at__extract_month AS created_at__extract_month - , subq_2.created_at__extract_day AS created_at__extract_day - , subq_2.created_at__extract_dow AS created_at__extract_dow - , subq_2.created_at__extract_doy AS created_at__extract_doy - , subq_2.listing__ds__day AS listing__ds__day - , subq_2.listing__ds__week AS listing__ds__week - , subq_2.listing__ds__month AS listing__ds__month - , subq_2.listing__ds__quarter AS listing__ds__quarter - , subq_2.listing__ds__year AS listing__ds__year - , subq_2.listing__ds__extract_year AS listing__ds__extract_year - , subq_2.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_2.listing__ds__extract_month AS listing__ds__extract_month - , subq_2.listing__ds__extract_day AS listing__ds__extract_day - , subq_2.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_2.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_2.listing__created_at__day AS listing__created_at__day - , subq_2.listing__created_at__week AS listing__created_at__week - , subq_2.listing__created_at__month AS listing__created_at__month - , subq_2.listing__created_at__quarter AS listing__created_at__quarter - , subq_2.listing__created_at__year AS listing__created_at__year - , subq_2.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_2.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_5.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.user AS user - , subq_2.listing__user AS listing__user - , subq_2.country_latest AS country_latest - , subq_2.is_lux_latest AS is_lux_latest - , subq_2.capacity_latest AS capacity_latest - , subq_2.listing__country_latest AS listing__country_latest - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_7.home_state_latest AS user__home_state_latest - , subq_2.listings AS listings - , subq_2.largest_listing AS largest_listing - , subq_2.smallest_listing AS smallest_listing + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_5.home_state_latest AS user__home_state_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -185,36 +185,36 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 + ) subq_0 CROSS JOIN ( -- Pass Only Elements: ['metric_time__day',] SELECT - subq_4.metric_time__day + subq_2.metric_time__day FROM ( -- Metric Time Dimension 'ds' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds__day AS metric_time__day + , subq_1.ds__week AS metric_time__week + , subq_1.ds__month AS metric_time__month + , subq_1.ds__quarter AS metric_time__quarter + , subq_1.ds__year AS metric_time__year + , subq_1.ds__extract_year AS metric_time__extract_year + , subq_1.ds__extract_quarter AS metric_time__extract_quarter + , subq_1.ds__extract_month AS metric_time__extract_month + , subq_1.ds__extract_day AS metric_time__extract_day + , subq_1.ds__extract_dow AS metric_time__extract_dow + , subq_1.ds__extract_doy AS metric_time__extract_doy FROM ( -- Time Spine SELECT @@ -230,14 +230,14 @@ FROM ( , EXTRACT(DAY_OF_WEEK FROM time_spine_src_28000.ds) AS ds__extract_dow , EXTRACT(doy FROM time_spine_src_28000.ds) AS ds__extract_doy FROM ***************************.mf_time_spine time_spine_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_1 + ) subq_2 + ) subq_3 FULL OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_6.user - , subq_6.home_state_latest + subq_4.user + , subq_4.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -267,14 +267,14 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 ON - subq_2.user = subq_7.user - ) subq_8 - WHERE subq_8.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-03' -) subq_9 + subq_0.user = subq_5.user + ) subq_6 + WHERE subq_6.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-03' +) subq_7 GROUP BY - subq_9.metric_time__day - , subq_9.listing__is_lux_latest - , subq_9.user__home_state_latest + subq_7.metric_time__day + , subq_7.listing__is_lux_latest + , subq_7.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_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 new file mode 100644 index 0000000000..3fdef1be70 --- /dev/null +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -0,0 +1,563 @@ +-- Compute Metrics via Expressions +SELECT + subq_15.metric_time__day + , CAST(subq_15.average_booking_value AS FLOAT64) / CAST(NULLIF(subq_15.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 + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_8.metric_time__day + , subq_8.average_booking_value + FROM ( + -- Aggregate Measures + SELECT + subq_7.metric_time__day + , AVG(subq_7.average_booking_value) AS average_booking_value + FROM ( + -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] + SELECT + subq_6.metric_time__day + , subq_6.average_booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.average_booking_value + FROM ( + -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.average_booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(bookings_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATE_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATE_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATE_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATE_TRUNC(bookings_source_src_28000.paid_at, year) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATE_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATE_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATE_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATE_TRUNC(bookings_source_src_28000.ds, year) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.ds) - 1) AS booking__ds__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, year) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATE_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATE_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATE_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + WHERE booking__is_instant + ) subq_4 + ) subq_5 + WHERE booking__is_instant + ) subq_6 + ) subq_7 + GROUP BY + metric_time__day + ) subq_8 + ) subq_9 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_13.metric_time__day + , subq_13.max_booking_value + FROM ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , MAX(subq_12.max_booking_value) AS max_booking_value + FROM ( + -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.max_booking_value + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATE_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATE_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATE_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATE_TRUNC(bookings_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATE_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATE_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATE_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATE_TRUNC(bookings_source_src_28000.paid_at, year) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATE_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATE_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATE_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATE_TRUNC(bookings_source_src_28000.ds, year) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.ds) - 1) AS booking__ds__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, year) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATE_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATE_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATE_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + metric_time__day + ) subq_13 + ) subq_14 + ON + subq_9.metric_time__day = subq_14.metric_time__day + GROUP BY + metric_time__day +) subq_15 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 new file mode 100644 index 0000000000..804265a8ac --- /dev/null +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -0,0 +1,58 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , CAST(average_booking_value AS FLOAT64) / CAST(NULLIF(max_booking_value, 0) AS FLOAT64) AS instant_booking_fraction_of_max_value +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.average_booking_value) AS average_booking_value + , MAX(subq_28.max_booking_value) AS max_booking_value + FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + metric_time__day + , AVG(average_booking_value) AS average_booking_value + FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + metric_time__day + , booking__is_instant + , average_booking_value + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + SELECT + DATE_TRUNC(ds, day) AS metric_time__day + , is_instant AS booking__is_instant + , booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_17 + WHERE booking__is_instant + ) subq_19 + WHERE booking__is_instant + GROUP BY + metric_time__day + ) subq_23 + FULL OUTER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + DATE_TRUNC(ds, day) AS metric_time__day + , MAX(booking_value) AS max_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 + GROUP BY + metric_time__day + ) subq_28 + ON + subq_23.metric_time__day = subq_28.metric_time__day + GROUP BY + metric_time__day +) subq_29 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 2338468a44..5257230f14 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,249 +1,48 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_12.user__home_state_latest + , subq_12.listings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_11.user__home_state_latest + , SUM(subq_11.listings) AS listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant'] + -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_10.user__home_state_latest + , subq_10.listings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.bookings + subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.user__home_state_latest + , subq_9.listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.bookings + subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.user__home_state_latest + , subq_8.listings FROM ( -- Join Standard Outputs SELECT - subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_5.capacity_latest AS listing__capacity_latest - , subq_2.bookings AS bookings + subq_5.user AS user + , subq_5.listing__is_lux_latest AS listing__is_lux_latest + , subq_5.listing__capacity_latest AS listing__capacity_latest + , subq_7.home_state_latest AS user__home_state_latest + , subq_5.listings AS listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_4.user + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATE_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATE_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATE_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATE_TRUNC(bookings_source_src_28000.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATE_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATE_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATE_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATE_TRUNC(bookings_source_src_28000.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATE_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATE_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATE_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATE_TRUNC(bookings_source_src_28000.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATE_TRUNC(bookings_source_src_28000.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATE_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATE_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATE_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATE_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'capacity_latest', 'listing', 'listing'] - SELECT - subq_4.listing - , subq_4.is_lux_latest - , subq_4.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + -- Constrain Output with WHERE SELECT subq_3.ds__day , subq_3.ds__week @@ -289,17 +88,17 @@ FROM ( , subq_3.listing__created_at__extract_day , subq_3.listing__created_at__extract_dow , subq_3.listing__created_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy , subq_3.listing , subq_3.user , subq_3.listing__user @@ -313,75 +112,183 @@ FROM ( , subq_3.largest_listing , subq_3.smallest_listing FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + SELECT + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 ) subq_3 + WHERE listing__is_lux_latest OR listing__capacity_latest > 4 ) subq_4 ) subq_5 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_6.user + , subq_6.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' + SELECT + DATE_TRUNC(users_latest_src_28000.ds, day) AS ds_latest__day + , DATE_TRUNC(users_latest_src_28000.ds, isoweek) AS ds_latest__week + , DATE_TRUNC(users_latest_src_28000.ds, month) AS ds_latest__month + , DATE_TRUNC(users_latest_src_28000.ds, quarter) AS ds_latest__quarter + , DATE_TRUNC(users_latest_src_28000.ds, year) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28000.ds) - 1) AS ds_latest__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_28000.ds) AS ds_latest__extract_doy + , users_latest_src_28000.home_state_latest + , DATE_TRUNC(users_latest_src_28000.ds, day) AS user__ds_latest__day + , DATE_TRUNC(users_latest_src_28000.ds, isoweek) AS user__ds_latest__week + , DATE_TRUNC(users_latest_src_28000.ds, month) AS user__ds_latest__month + , DATE_TRUNC(users_latest_src_28000.ds, quarter) AS user__ds_latest__quarter + , DATE_TRUNC(users_latest_src_28000.ds, year) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day + , IF(EXTRACT(dayofweek FROM users_latest_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28000.ds) - 1) AS user__ds_latest__extract_dow + , EXTRACT(dayofyear FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , users_latest_src_28000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_28000 + ) subq_6 + ) subq_7 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_5.user = subq_7.user + ) subq_8 + ) subq_9 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_8 - ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - booking__is_instant -) subq_10 + user__home_state_latest +) subq_12 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 98cc26bb70..76b28308ab 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 @@ -1,33 +1,43 @@ -- Constrain Output with WHERE --- Pass Only Elements: ['bookings', 'booking__is_instant'] +-- Pass Only Elements: ['listings', 'user__home_state_latest'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - booking__is_instant - , SUM(bookings) AS bookings + user__home_state_latest + , SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_13.bookings AS bookings + subq_16.listing__is_lux_latest AS listing__is_lux_latest + , subq_16.listing__capacity_latest AS listing__capacity_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_16.listings AS listings FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Constrain Output with WHERE + -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - listing_id AS listing - , is_instant AS booking__is_instant - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + subq_14.user + , listing__is_lux_latest + , listing__capacity_latest + , listings + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' + SELECT + user_id AS user + , is_lux AS listing__is_lux_latest + , capacity AS listing__capacity_latest + , 1 AS listings + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_14 + WHERE listing__is_lux_latest OR listing__capacity_latest > 4 + ) subq_16 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28000 + ***************************.dim_users_latest users_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_16.user = users_latest_src_28000.user_id +) subq_20 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY - booking__is_instant + user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 01e8c2274d..ce29f70718 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_17.listing__country_latest - , subq_17.bookings + subq_13.listing__country_latest + , subq_13.bookings FROM ( -- Aggregate Measures SELECT - subq_16.listing__country_latest - , SUM(subq_16.bookings) AS bookings + subq_12.listing__country_latest + , SUM(subq_12.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_15.listing__country_latest - , subq_15.bookings + subq_11.listing__country_latest + , subq_11.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_14.booking__is_instant - , subq_14.listing__country_latest - , subq_14.bookings + subq_10.booking__is_instant + , subq_10.listing__country_latest + , subq_10.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant - , subq_13.listing__country_latest - , subq_13.bookings + subq_9.booking__is_instant + , subq_9.listing__country_latest + , subq_9.bookings FROM ( -- Join Standard Outputs SELECT - subq_9.listing AS listing - , subq_9.booking__is_instant AS booking__is_instant - , subq_12.country_latest AS listing__country_latest - , subq_9.bookings AS bookings + subq_5.listing AS listing + , subq_5.booking__is_instant AS booking__is_instant + , subq_8.country_latest AS listing__country_latest + , subq_5.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_8.listing - , subq_8.booking__is_instant - , subq_8.bookings + subq_4.listing + , subq_4.booking__is_instant + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -331,86 +331,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_11.listing - , subq_11.country_latest + subq_7.listing + , subq_7.country_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.created_at__day - , subq_10.created_at__week - , subq_10.created_at__month - , subq_10.created_at__quarter - , subq_10.created_at__year - , subq_10.created_at__extract_year - , subq_10.created_at__extract_quarter - , subq_10.created_at__extract_month - , subq_10.created_at__extract_day - , subq_10.created_at__extract_dow - , subq_10.created_at__extract_doy - , subq_10.listing__ds__day - , subq_10.listing__ds__week - , subq_10.listing__ds__month - , subq_10.listing__ds__quarter - , subq_10.listing__ds__year - , subq_10.listing__ds__extract_year - , subq_10.listing__ds__extract_quarter - , subq_10.listing__ds__extract_month - , subq_10.listing__ds__extract_day - , subq_10.listing__ds__extract_dow - , subq_10.listing__ds__extract_doy - , subq_10.listing__created_at__day - , subq_10.listing__created_at__week - , subq_10.listing__created_at__month - , subq_10.listing__created_at__quarter - , subq_10.listing__created_at__year - , subq_10.listing__created_at__extract_year - , subq_10.listing__created_at__extract_quarter - , subq_10.listing__created_at__extract_month - , subq_10.listing__created_at__extract_day - , subq_10.listing__created_at__extract_dow - , subq_10.listing__created_at__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.listing - , subq_10.user - , subq_10.listing__user - , subq_10.country_latest - , subq_10.is_lux_latest - , subq_10.capacity_latest - , subq_10.listing__country_latest - , subq_10.listing__is_lux_latest - , subq_10.listing__capacity_latest - , subq_10.listings - , subq_10.largest_listing - , subq_10.smallest_listing + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.created_at__day + , subq_6.created_at__week + , subq_6.created_at__month + , subq_6.created_at__quarter + , subq_6.created_at__year + , subq_6.created_at__extract_year + , subq_6.created_at__extract_quarter + , subq_6.created_at__extract_month + , subq_6.created_at__extract_day + , subq_6.created_at__extract_dow + , subq_6.created_at__extract_doy + , subq_6.listing__ds__day + , subq_6.listing__ds__week + , subq_6.listing__ds__month + , subq_6.listing__ds__quarter + , subq_6.listing__ds__year + , subq_6.listing__ds__extract_year + , subq_6.listing__ds__extract_quarter + , subq_6.listing__ds__extract_month + , subq_6.listing__ds__extract_day + , subq_6.listing__ds__extract_dow + , subq_6.listing__ds__extract_doy + , subq_6.listing__created_at__day + , subq_6.listing__created_at__week + , subq_6.listing__created_at__month + , subq_6.listing__created_at__quarter + , subq_6.listing__created_at__year + , subq_6.listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month + , subq_6.listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.user + , subq_6.listing__user + , subq_6.country_latest + , subq_6.is_lux_latest + , subq_6.capacity_latest + , subq_6.listing__country_latest + , subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.listings + , subq_6.largest_listing + , subq_6.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -471,16 +471,16 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_9.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_5.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE booking__is_instant - ) subq_15 - ) subq_16 + ) subq_11 + ) subq_12 GROUP BY listing__country_latest -) subq_17 +) subq_13 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 b0a46663de..e1420879c4 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_21.booking__is_instant AS booking__is_instant + subq_17.booking__is_instant AS booking__is_instant , listings_latest_src_28000.country AS listing__country_latest - , subq_21.bookings AS bookings + , subq_17.bookings AS bookings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] @@ -27,14 +27,14 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_21.listing = listings_latest_src_28000.listing_id -) subq_26 + subq_17.listing = listings_latest_src_28000.listing_id +) subq_22 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_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 new file mode 100644 index 0000000000..5d770f3f36 --- /dev/null +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -0,0 +1,563 @@ +-- Compute Metrics via Expressions +SELECT + subq_15.metric_time__day + , CAST(subq_15.average_booking_value AS DOUBLE) / CAST(NULLIF(subq_15.max_booking_value, 0) AS DOUBLE) AS instant_booking_fraction_of_max_value +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) AS metric_time__day + , MAX(subq_9.average_booking_value) AS average_booking_value + , MAX(subq_14.max_booking_value) AS max_booking_value + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_8.metric_time__day + , subq_8.average_booking_value + FROM ( + -- Aggregate Measures + SELECT + subq_7.metric_time__day + , AVG(subq_7.average_booking_value) AS average_booking_value + FROM ( + -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] + SELECT + subq_6.metric_time__day + , subq_6.average_booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.average_booking_value + FROM ( + -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.average_booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + WHERE booking__is_instant + ) subq_4 + ) subq_5 + WHERE booking__is_instant + ) subq_6 + ) subq_7 + GROUP BY + subq_7.metric_time__day + ) subq_8 + ) subq_9 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_13.metric_time__day + , subq_13.max_booking_value + FROM ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , MAX(subq_12.max_booking_value) AS max_booking_value + FROM ( + -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.max_booking_value + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.metric_time__day + ) subq_13 + ) subq_14 + ON + subq_9.metric_time__day = subq_14.metric_time__day + GROUP BY + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) +) subq_15 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 new file mode 100644 index 0000000000..db345ac389 --- /dev/null +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -0,0 +1,58 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , CAST(average_booking_value AS DOUBLE) / CAST(NULLIF(max_booking_value, 0) AS DOUBLE) AS instant_booking_fraction_of_max_value +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.average_booking_value) AS average_booking_value + , MAX(subq_28.max_booking_value) AS max_booking_value + FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + metric_time__day + , AVG(average_booking_value) AS average_booking_value + FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + metric_time__day + , booking__is_instant + , average_booking_value + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , is_instant AS booking__is_instant + , booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_17 + WHERE booking__is_instant + ) subq_19 + WHERE booking__is_instant + GROUP BY + metric_time__day + ) subq_23 + FULL OUTER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , MAX(booking_value) AS max_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_28 + ON + subq_23.metric_time__day = subq_28.metric_time__day + GROUP BY + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) +) subq_29 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 bc12b03102..35f2ac06a8 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,249 +1,48 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_12.user__home_state_latest + , subq_12.listings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_11.user__home_state_latest + , SUM(subq_11.listings) AS listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant'] + -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_10.user__home_state_latest + , subq_10.listings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.bookings + subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.user__home_state_latest + , subq_9.listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.bookings + subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.user__home_state_latest + , subq_8.listings FROM ( -- Join Standard Outputs SELECT - subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_5.capacity_latest AS listing__capacity_latest - , subq_2.bookings AS bookings + subq_5.user AS user + , subq_5.listing__is_lux_latest AS listing__is_lux_latest + , subq_5.listing__capacity_latest AS listing__capacity_latest + , subq_7.home_state_latest AS user__home_state_latest + , subq_5.listings AS listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_4.user + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'capacity_latest', 'listing', 'listing'] - SELECT - subq_4.listing - , subq_4.is_lux_latest - , subq_4.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + -- Constrain Output with WHERE SELECT subq_3.ds__day , subq_3.ds__week @@ -289,17 +88,17 @@ FROM ( , subq_3.listing__created_at__extract_day , subq_3.listing__created_at__extract_dow , subq_3.listing__created_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy , subq_3.listing , subq_3.user , subq_3.listing__user @@ -313,75 +112,183 @@ FROM ( , subq_3.largest_listing , subq_3.smallest_listing FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + SELECT + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 ) subq_3 + WHERE listing__is_lux_latest OR listing__capacity_latest > 4 ) subq_4 ) subq_5 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_6.user + , subq_6.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' + SELECT + DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28000.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy + , users_latest_src_28000.home_state_latest + , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , users_latest_src_28000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_28000 + ) subq_6 + ) subq_7 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_5.user = subq_7.user + ) subq_8 + ) subq_9 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_8 - ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_11.user__home_state_latest +) subq_12 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 98cc26bb70..76b28308ab 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 @@ -1,33 +1,43 @@ -- Constrain Output with WHERE --- Pass Only Elements: ['bookings', 'booking__is_instant'] +-- Pass Only Elements: ['listings', 'user__home_state_latest'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - booking__is_instant - , SUM(bookings) AS bookings + user__home_state_latest + , SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_13.bookings AS bookings + subq_16.listing__is_lux_latest AS listing__is_lux_latest + , subq_16.listing__capacity_latest AS listing__capacity_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_16.listings AS listings FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Constrain Output with WHERE + -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - listing_id AS listing - , is_instant AS booking__is_instant - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + subq_14.user + , listing__is_lux_latest + , listing__capacity_latest + , listings + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' + SELECT + user_id AS user + , is_lux AS listing__is_lux_latest + , capacity AS listing__capacity_latest + , 1 AS listings + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_14 + WHERE listing__is_lux_latest OR listing__capacity_latest > 4 + ) subq_16 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28000 + ***************************.dim_users_latest users_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_16.user = users_latest_src_28000.user_id +) subq_20 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY - booking__is_instant + user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 85f5d39687..41d8a84d8a 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_17.listing__country_latest - , subq_17.bookings + subq_13.listing__country_latest + , subq_13.bookings FROM ( -- Aggregate Measures SELECT - subq_16.listing__country_latest - , SUM(subq_16.bookings) AS bookings + subq_12.listing__country_latest + , SUM(subq_12.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_15.listing__country_latest - , subq_15.bookings + subq_11.listing__country_latest + , subq_11.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_14.booking__is_instant - , subq_14.listing__country_latest - , subq_14.bookings + subq_10.booking__is_instant + , subq_10.listing__country_latest + , subq_10.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant - , subq_13.listing__country_latest - , subq_13.bookings + subq_9.booking__is_instant + , subq_9.listing__country_latest + , subq_9.bookings FROM ( -- Join Standard Outputs SELECT - subq_9.listing AS listing - , subq_9.booking__is_instant AS booking__is_instant - , subq_12.country_latest AS listing__country_latest - , subq_9.bookings AS bookings + subq_5.listing AS listing + , subq_5.booking__is_instant AS booking__is_instant + , subq_8.country_latest AS listing__country_latest + , subq_5.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_8.listing - , subq_8.booking__is_instant - , subq_8.bookings + subq_4.listing + , subq_4.booking__is_instant + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -331,86 +331,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_11.listing - , subq_11.country_latest + subq_7.listing + , subq_7.country_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.created_at__day - , subq_10.created_at__week - , subq_10.created_at__month - , subq_10.created_at__quarter - , subq_10.created_at__year - , subq_10.created_at__extract_year - , subq_10.created_at__extract_quarter - , subq_10.created_at__extract_month - , subq_10.created_at__extract_day - , subq_10.created_at__extract_dow - , subq_10.created_at__extract_doy - , subq_10.listing__ds__day - , subq_10.listing__ds__week - , subq_10.listing__ds__month - , subq_10.listing__ds__quarter - , subq_10.listing__ds__year - , subq_10.listing__ds__extract_year - , subq_10.listing__ds__extract_quarter - , subq_10.listing__ds__extract_month - , subq_10.listing__ds__extract_day - , subq_10.listing__ds__extract_dow - , subq_10.listing__ds__extract_doy - , subq_10.listing__created_at__day - , subq_10.listing__created_at__week - , subq_10.listing__created_at__month - , subq_10.listing__created_at__quarter - , subq_10.listing__created_at__year - , subq_10.listing__created_at__extract_year - , subq_10.listing__created_at__extract_quarter - , subq_10.listing__created_at__extract_month - , subq_10.listing__created_at__extract_day - , subq_10.listing__created_at__extract_dow - , subq_10.listing__created_at__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.listing - , subq_10.user - , subq_10.listing__user - , subq_10.country_latest - , subq_10.is_lux_latest - , subq_10.capacity_latest - , subq_10.listing__country_latest - , subq_10.listing__is_lux_latest - , subq_10.listing__capacity_latest - , subq_10.listings - , subq_10.largest_listing - , subq_10.smallest_listing + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.created_at__day + , subq_6.created_at__week + , subq_6.created_at__month + , subq_6.created_at__quarter + , subq_6.created_at__year + , subq_6.created_at__extract_year + , subq_6.created_at__extract_quarter + , subq_6.created_at__extract_month + , subq_6.created_at__extract_day + , subq_6.created_at__extract_dow + , subq_6.created_at__extract_doy + , subq_6.listing__ds__day + , subq_6.listing__ds__week + , subq_6.listing__ds__month + , subq_6.listing__ds__quarter + , subq_6.listing__ds__year + , subq_6.listing__ds__extract_year + , subq_6.listing__ds__extract_quarter + , subq_6.listing__ds__extract_month + , subq_6.listing__ds__extract_day + , subq_6.listing__ds__extract_dow + , subq_6.listing__ds__extract_doy + , subq_6.listing__created_at__day + , subq_6.listing__created_at__week + , subq_6.listing__created_at__month + , subq_6.listing__created_at__quarter + , subq_6.listing__created_at__year + , subq_6.listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month + , subq_6.listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.user + , subq_6.listing__user + , subq_6.country_latest + , subq_6.is_lux_latest + , subq_6.capacity_latest + , subq_6.listing__country_latest + , subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.listings + , subq_6.largest_listing + , subq_6.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -471,16 +471,16 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_9.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_5.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE booking__is_instant - ) subq_15 - ) subq_16 + ) subq_11 + ) subq_12 GROUP BY - subq_16.listing__country_latest -) subq_17 + subq_12.listing__country_latest +) subq_13 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 b0a46663de..e1420879c4 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_21.booking__is_instant AS booking__is_instant + subq_17.booking__is_instant AS booking__is_instant , listings_latest_src_28000.country AS listing__country_latest - , subq_21.bookings AS bookings + , subq_17.bookings AS bookings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] @@ -27,14 +27,14 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_21.listing = listings_latest_src_28000.listing_id -) subq_26 + subq_17.listing = listings_latest_src_28000.listing_id +) subq_22 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_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 new file mode 100644 index 0000000000..9912778c27 --- /dev/null +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -0,0 +1,563 @@ +-- Compute Metrics via Expressions +SELECT + subq_15.metric_time__day + , CAST(subq_15.average_booking_value AS DOUBLE PRECISION) / CAST(NULLIF(subq_15.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 + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_8.metric_time__day + , subq_8.average_booking_value + FROM ( + -- Aggregate Measures + SELECT + subq_7.metric_time__day + , AVG(subq_7.average_booking_value) AS average_booking_value + FROM ( + -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] + SELECT + subq_6.metric_time__day + , subq_6.average_booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.average_booking_value + FROM ( + -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.average_booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + WHERE booking__is_instant + ) subq_4 + ) subq_5 + WHERE booking__is_instant + ) subq_6 + ) subq_7 + GROUP BY + subq_7.metric_time__day + ) subq_8 + ) subq_9 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_13.metric_time__day + , subq_13.max_booking_value + FROM ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , MAX(subq_12.max_booking_value) AS max_booking_value + FROM ( + -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.max_booking_value + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.metric_time__day + ) subq_13 + ) subq_14 + ON + subq_9.metric_time__day = subq_14.metric_time__day + GROUP BY + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) +) subq_15 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 new file mode 100644 index 0000000000..0c1698db23 --- /dev/null +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -0,0 +1,58 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , CAST(average_booking_value AS DOUBLE PRECISION) / CAST(NULLIF(max_booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_fraction_of_max_value +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.average_booking_value) AS average_booking_value + , MAX(subq_28.max_booking_value) AS max_booking_value + FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + metric_time__day + , AVG(average_booking_value) AS average_booking_value + FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + metric_time__day + , booking__is_instant + , average_booking_value + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , is_instant AS booking__is_instant + , booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_17 + WHERE booking__is_instant + ) subq_19 + WHERE booking__is_instant + GROUP BY + metric_time__day + ) subq_23 + FULL OUTER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , MAX(booking_value) AS max_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_28 + ON + subq_23.metric_time__day = subq_28.metric_time__day + GROUP BY + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) +) subq_29 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 c864c9883c..e20f1a70d6 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,249 +1,48 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_12.user__home_state_latest + , subq_12.listings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_11.user__home_state_latest + , SUM(subq_11.listings) AS listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant'] + -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_10.user__home_state_latest + , subq_10.listings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.bookings + subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.user__home_state_latest + , subq_9.listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.bookings + subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.user__home_state_latest + , subq_8.listings FROM ( -- Join Standard Outputs SELECT - subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_5.capacity_latest AS listing__capacity_latest - , subq_2.bookings AS bookings + subq_5.user AS user + , subq_5.listing__is_lux_latest AS listing__is_lux_latest + , subq_5.listing__capacity_latest AS listing__capacity_latest + , subq_7.home_state_latest AS user__home_state_latest + , subq_5.listings AS listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_4.user + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'capacity_latest', 'listing', 'listing'] - SELECT - subq_4.listing - , subq_4.is_lux_latest - , subq_4.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + -- Constrain Output with WHERE SELECT subq_3.ds__day , subq_3.ds__week @@ -289,17 +88,17 @@ FROM ( , subq_3.listing__created_at__extract_day , subq_3.listing__created_at__extract_dow , subq_3.listing__created_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy , subq_3.listing , subq_3.user , subq_3.listing__user @@ -313,75 +112,183 @@ FROM ( , subq_3.largest_listing , subq_3.smallest_listing FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + SELECT + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 ) subq_3 + WHERE listing__is_lux_latest OR listing__capacity_latest > 4 ) subq_4 ) subq_5 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_6.user + , subq_6.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' + SELECT + DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_28000.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy + , users_latest_src_28000.home_state_latest + , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day + , EXTRACT(isodow FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , users_latest_src_28000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_28000 + ) subq_6 + ) subq_7 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_5.user = subq_7.user + ) subq_8 + ) subq_9 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_8 - ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_11.user__home_state_latest +) subq_12 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 98cc26bb70..76b28308ab 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 @@ -1,33 +1,43 @@ -- Constrain Output with WHERE --- Pass Only Elements: ['bookings', 'booking__is_instant'] +-- Pass Only Elements: ['listings', 'user__home_state_latest'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - booking__is_instant - , SUM(bookings) AS bookings + user__home_state_latest + , SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_13.bookings AS bookings + subq_16.listing__is_lux_latest AS listing__is_lux_latest + , subq_16.listing__capacity_latest AS listing__capacity_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_16.listings AS listings FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Constrain Output with WHERE + -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - listing_id AS listing - , is_instant AS booking__is_instant - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + subq_14.user + , listing__is_lux_latest + , listing__capacity_latest + , listings + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' + SELECT + user_id AS user + , is_lux AS listing__is_lux_latest + , capacity AS listing__capacity_latest + , 1 AS listings + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_14 + WHERE listing__is_lux_latest OR listing__capacity_latest > 4 + ) subq_16 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28000 + ***************************.dim_users_latest users_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_16.user = users_latest_src_28000.user_id +) subq_20 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY - booking__is_instant + user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 5ef5778430..388b3ec95a 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_17.listing__country_latest - , subq_17.bookings + subq_13.listing__country_latest + , subq_13.bookings FROM ( -- Aggregate Measures SELECT - subq_16.listing__country_latest - , SUM(subq_16.bookings) AS bookings + subq_12.listing__country_latest + , SUM(subq_12.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_15.listing__country_latest - , subq_15.bookings + subq_11.listing__country_latest + , subq_11.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_14.booking__is_instant - , subq_14.listing__country_latest - , subq_14.bookings + subq_10.booking__is_instant + , subq_10.listing__country_latest + , subq_10.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant - , subq_13.listing__country_latest - , subq_13.bookings + subq_9.booking__is_instant + , subq_9.listing__country_latest + , subq_9.bookings FROM ( -- Join Standard Outputs SELECT - subq_9.listing AS listing - , subq_9.booking__is_instant AS booking__is_instant - , subq_12.country_latest AS listing__country_latest - , subq_9.bookings AS bookings + subq_5.listing AS listing + , subq_5.booking__is_instant AS booking__is_instant + , subq_8.country_latest AS listing__country_latest + , subq_5.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_8.listing - , subq_8.booking__is_instant - , subq_8.bookings + subq_4.listing + , subq_4.booking__is_instant + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -331,86 +331,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_11.listing - , subq_11.country_latest + subq_7.listing + , subq_7.country_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.created_at__day - , subq_10.created_at__week - , subq_10.created_at__month - , subq_10.created_at__quarter - , subq_10.created_at__year - , subq_10.created_at__extract_year - , subq_10.created_at__extract_quarter - , subq_10.created_at__extract_month - , subq_10.created_at__extract_day - , subq_10.created_at__extract_dow - , subq_10.created_at__extract_doy - , subq_10.listing__ds__day - , subq_10.listing__ds__week - , subq_10.listing__ds__month - , subq_10.listing__ds__quarter - , subq_10.listing__ds__year - , subq_10.listing__ds__extract_year - , subq_10.listing__ds__extract_quarter - , subq_10.listing__ds__extract_month - , subq_10.listing__ds__extract_day - , subq_10.listing__ds__extract_dow - , subq_10.listing__ds__extract_doy - , subq_10.listing__created_at__day - , subq_10.listing__created_at__week - , subq_10.listing__created_at__month - , subq_10.listing__created_at__quarter - , subq_10.listing__created_at__year - , subq_10.listing__created_at__extract_year - , subq_10.listing__created_at__extract_quarter - , subq_10.listing__created_at__extract_month - , subq_10.listing__created_at__extract_day - , subq_10.listing__created_at__extract_dow - , subq_10.listing__created_at__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.listing - , subq_10.user - , subq_10.listing__user - , subq_10.country_latest - , subq_10.is_lux_latest - , subq_10.capacity_latest - , subq_10.listing__country_latest - , subq_10.listing__is_lux_latest - , subq_10.listing__capacity_latest - , subq_10.listings - , subq_10.largest_listing - , subq_10.smallest_listing + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.created_at__day + , subq_6.created_at__week + , subq_6.created_at__month + , subq_6.created_at__quarter + , subq_6.created_at__year + , subq_6.created_at__extract_year + , subq_6.created_at__extract_quarter + , subq_6.created_at__extract_month + , subq_6.created_at__extract_day + , subq_6.created_at__extract_dow + , subq_6.created_at__extract_doy + , subq_6.listing__ds__day + , subq_6.listing__ds__week + , subq_6.listing__ds__month + , subq_6.listing__ds__quarter + , subq_6.listing__ds__year + , subq_6.listing__ds__extract_year + , subq_6.listing__ds__extract_quarter + , subq_6.listing__ds__extract_month + , subq_6.listing__ds__extract_day + , subq_6.listing__ds__extract_dow + , subq_6.listing__ds__extract_doy + , subq_6.listing__created_at__day + , subq_6.listing__created_at__week + , subq_6.listing__created_at__month + , subq_6.listing__created_at__quarter + , subq_6.listing__created_at__year + , subq_6.listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month + , subq_6.listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.user + , subq_6.listing__user + , subq_6.country_latest + , subq_6.is_lux_latest + , subq_6.capacity_latest + , subq_6.listing__country_latest + , subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.listings + , subq_6.largest_listing + , subq_6.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -471,16 +471,16 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_9.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_5.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE booking__is_instant - ) subq_15 - ) subq_16 + ) subq_11 + ) subq_12 GROUP BY - subq_16.listing__country_latest -) subq_17 + subq_12.listing__country_latest +) subq_13 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 b0a46663de..e1420879c4 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_21.booking__is_instant AS booking__is_instant + subq_17.booking__is_instant AS booking__is_instant , listings_latest_src_28000.country AS listing__country_latest - , subq_21.bookings AS bookings + , subq_17.bookings AS bookings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] @@ -27,14 +27,14 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_21.listing = listings_latest_src_28000.listing_id -) subq_26 + subq_17.listing = listings_latest_src_28000.listing_id +) subq_22 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_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 new file mode 100644 index 0000000000..6a9a9bf836 --- /dev/null +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -0,0 +1,563 @@ +-- Compute Metrics via Expressions +SELECT + subq_15.metric_time__day + , CAST(subq_15.average_booking_value AS DOUBLE PRECISION) / CAST(NULLIF(subq_15.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 + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_8.metric_time__day + , subq_8.average_booking_value + FROM ( + -- Aggregate Measures + SELECT + subq_7.metric_time__day + , AVG(subq_7.average_booking_value) AS average_booking_value + FROM ( + -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] + SELECT + subq_6.metric_time__day + , subq_6.average_booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.average_booking_value + FROM ( + -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.average_booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + WHERE booking__is_instant + ) subq_4 + ) subq_5 + WHERE booking__is_instant + ) subq_6 + ) subq_7 + GROUP BY + subq_7.metric_time__day + ) subq_8 + ) subq_9 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_13.metric_time__day + , subq_13.max_booking_value + FROM ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , MAX(subq_12.max_booking_value) AS max_booking_value + FROM ( + -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.max_booking_value + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.metric_time__day + ) subq_13 + ) subq_14 + ON + subq_9.metric_time__day = subq_14.metric_time__day + GROUP BY + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) +) subq_15 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 new file mode 100644 index 0000000000..0c1698db23 --- /dev/null +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -0,0 +1,58 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , CAST(average_booking_value AS DOUBLE PRECISION) / CAST(NULLIF(max_booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_fraction_of_max_value +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.average_booking_value) AS average_booking_value + , MAX(subq_28.max_booking_value) AS max_booking_value + FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + metric_time__day + , AVG(average_booking_value) AS average_booking_value + FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + metric_time__day + , booking__is_instant + , average_booking_value + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , is_instant AS booking__is_instant + , booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_17 + WHERE booking__is_instant + ) subq_19 + WHERE booking__is_instant + GROUP BY + metric_time__day + ) subq_23 + FULL OUTER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , MAX(booking_value) AS max_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_28 + ON + subq_23.metric_time__day = subq_28.metric_time__day + GROUP BY + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) +) subq_29 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 824975c8c3..e889913967 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,249 +1,48 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_12.user__home_state_latest + , subq_12.listings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_11.user__home_state_latest + , SUM(subq_11.listings) AS listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant'] + -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_10.user__home_state_latest + , subq_10.listings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.bookings + subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.user__home_state_latest + , subq_9.listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.bookings + subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.user__home_state_latest + , subq_8.listings FROM ( -- Join Standard Outputs SELECT - subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_5.capacity_latest AS listing__capacity_latest - , subq_2.bookings AS bookings + subq_5.user AS user + , subq_5.listing__is_lux_latest AS listing__is_lux_latest + , subq_5.listing__capacity_latest AS listing__capacity_latest + , subq_7.home_state_latest AS user__home_state_latest + , subq_5.listings AS listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_4.user + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'capacity_latest', 'listing', 'listing'] - SELECT - subq_4.listing - , subq_4.is_lux_latest - , subq_4.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + -- Constrain Output with WHERE SELECT subq_3.ds__day , subq_3.ds__week @@ -289,17 +88,17 @@ FROM ( , subq_3.listing__created_at__extract_day , subq_3.listing__created_at__extract_dow , subq_3.listing__created_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy , subq_3.listing , subq_3.user , subq_3.listing__user @@ -313,75 +112,183 @@ FROM ( , subq_3.largest_listing , subq_3.smallest_listing FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + SELECT + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 ) subq_3 + WHERE listing__is_lux_latest OR listing__capacity_latest > 4 ) subq_4 ) subq_5 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_6.user + , subq_6.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' + SELECT + DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28000.ds) END AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy + , users_latest_src_28000.home_state_latest + , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day + , CASE WHEN EXTRACT(dow FROM users_latest_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28000.ds) END AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , users_latest_src_28000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_28000 + ) subq_6 + ) subq_7 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_5.user = subq_7.user + ) subq_8 + ) subq_9 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_8 - ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_11.user__home_state_latest +) subq_12 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 98cc26bb70..76b28308ab 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 @@ -1,33 +1,43 @@ -- Constrain Output with WHERE --- Pass Only Elements: ['bookings', 'booking__is_instant'] +-- Pass Only Elements: ['listings', 'user__home_state_latest'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - booking__is_instant - , SUM(bookings) AS bookings + user__home_state_latest + , SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_13.bookings AS bookings + subq_16.listing__is_lux_latest AS listing__is_lux_latest + , subq_16.listing__capacity_latest AS listing__capacity_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_16.listings AS listings FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Constrain Output with WHERE + -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - listing_id AS listing - , is_instant AS booking__is_instant - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + subq_14.user + , listing__is_lux_latest + , listing__capacity_latest + , listings + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' + SELECT + user_id AS user + , is_lux AS listing__is_lux_latest + , capacity AS listing__capacity_latest + , 1 AS listings + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_14 + WHERE listing__is_lux_latest OR listing__capacity_latest > 4 + ) subq_16 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28000 + ***************************.dim_users_latest users_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_16.user = users_latest_src_28000.user_id +) subq_20 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY - booking__is_instant + user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 3a611771e1..107ed57509 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_17.listing__country_latest - , subq_17.bookings + subq_13.listing__country_latest + , subq_13.bookings FROM ( -- Aggregate Measures SELECT - subq_16.listing__country_latest - , SUM(subq_16.bookings) AS bookings + subq_12.listing__country_latest + , SUM(subq_12.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_15.listing__country_latest - , subq_15.bookings + subq_11.listing__country_latest + , subq_11.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_14.booking__is_instant - , subq_14.listing__country_latest - , subq_14.bookings + subq_10.booking__is_instant + , subq_10.listing__country_latest + , subq_10.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant - , subq_13.listing__country_latest - , subq_13.bookings + subq_9.booking__is_instant + , subq_9.listing__country_latest + , subq_9.bookings FROM ( -- Join Standard Outputs SELECT - subq_9.listing AS listing - , subq_9.booking__is_instant AS booking__is_instant - , subq_12.country_latest AS listing__country_latest - , subq_9.bookings AS bookings + subq_5.listing AS listing + , subq_5.booking__is_instant AS booking__is_instant + , subq_8.country_latest AS listing__country_latest + , subq_5.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_8.listing - , subq_8.booking__is_instant - , subq_8.bookings + subq_4.listing + , subq_4.booking__is_instant + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -331,86 +331,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_11.listing - , subq_11.country_latest + subq_7.listing + , subq_7.country_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.created_at__day - , subq_10.created_at__week - , subq_10.created_at__month - , subq_10.created_at__quarter - , subq_10.created_at__year - , subq_10.created_at__extract_year - , subq_10.created_at__extract_quarter - , subq_10.created_at__extract_month - , subq_10.created_at__extract_day - , subq_10.created_at__extract_dow - , subq_10.created_at__extract_doy - , subq_10.listing__ds__day - , subq_10.listing__ds__week - , subq_10.listing__ds__month - , subq_10.listing__ds__quarter - , subq_10.listing__ds__year - , subq_10.listing__ds__extract_year - , subq_10.listing__ds__extract_quarter - , subq_10.listing__ds__extract_month - , subq_10.listing__ds__extract_day - , subq_10.listing__ds__extract_dow - , subq_10.listing__ds__extract_doy - , subq_10.listing__created_at__day - , subq_10.listing__created_at__week - , subq_10.listing__created_at__month - , subq_10.listing__created_at__quarter - , subq_10.listing__created_at__year - , subq_10.listing__created_at__extract_year - , subq_10.listing__created_at__extract_quarter - , subq_10.listing__created_at__extract_month - , subq_10.listing__created_at__extract_day - , subq_10.listing__created_at__extract_dow - , subq_10.listing__created_at__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.listing - , subq_10.user - , subq_10.listing__user - , subq_10.country_latest - , subq_10.is_lux_latest - , subq_10.capacity_latest - , subq_10.listing__country_latest - , subq_10.listing__is_lux_latest - , subq_10.listing__capacity_latest - , subq_10.listings - , subq_10.largest_listing - , subq_10.smallest_listing + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.created_at__day + , subq_6.created_at__week + , subq_6.created_at__month + , subq_6.created_at__quarter + , subq_6.created_at__year + , subq_6.created_at__extract_year + , subq_6.created_at__extract_quarter + , subq_6.created_at__extract_month + , subq_6.created_at__extract_day + , subq_6.created_at__extract_dow + , subq_6.created_at__extract_doy + , subq_6.listing__ds__day + , subq_6.listing__ds__week + , subq_6.listing__ds__month + , subq_6.listing__ds__quarter + , subq_6.listing__ds__year + , subq_6.listing__ds__extract_year + , subq_6.listing__ds__extract_quarter + , subq_6.listing__ds__extract_month + , subq_6.listing__ds__extract_day + , subq_6.listing__ds__extract_dow + , subq_6.listing__ds__extract_doy + , subq_6.listing__created_at__day + , subq_6.listing__created_at__week + , subq_6.listing__created_at__month + , subq_6.listing__created_at__quarter + , subq_6.listing__created_at__year + , subq_6.listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month + , subq_6.listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.user + , subq_6.listing__user + , subq_6.country_latest + , subq_6.is_lux_latest + , subq_6.capacity_latest + , subq_6.listing__country_latest + , subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.listings + , subq_6.largest_listing + , subq_6.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -471,16 +471,16 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_9.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_5.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE booking__is_instant - ) subq_15 - ) subq_16 + ) subq_11 + ) subq_12 GROUP BY - subq_16.listing__country_latest -) subq_17 + subq_12.listing__country_latest +) subq_13 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 b0a46663de..e1420879c4 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_21.booking__is_instant AS booking__is_instant + subq_17.booking__is_instant AS booking__is_instant , listings_latest_src_28000.country AS listing__country_latest - , subq_21.bookings AS bookings + , subq_17.bookings AS bookings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] @@ -27,14 +27,14 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_21.listing = listings_latest_src_28000.listing_id -) subq_26 + subq_17.listing = listings_latest_src_28000.listing_id +) subq_22 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_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 new file mode 100644 index 0000000000..b99de580a3 --- /dev/null +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -0,0 +1,563 @@ +-- Compute Metrics via Expressions +SELECT + subq_15.metric_time__day + , CAST(subq_15.average_booking_value AS DOUBLE) / CAST(NULLIF(subq_15.max_booking_value, 0) AS DOUBLE) AS instant_booking_fraction_of_max_value +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) AS metric_time__day + , MAX(subq_9.average_booking_value) AS average_booking_value + , MAX(subq_14.max_booking_value) AS max_booking_value + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_8.metric_time__day + , subq_8.average_booking_value + FROM ( + -- Aggregate Measures + SELECT + subq_7.metric_time__day + , AVG(subq_7.average_booking_value) AS average_booking_value + FROM ( + -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] + SELECT + subq_6.metric_time__day + , subq_6.average_booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.average_booking_value + FROM ( + -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.average_booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + WHERE booking__is_instant + ) subq_4 + ) subq_5 + WHERE booking__is_instant + ) subq_6 + ) subq_7 + GROUP BY + subq_7.metric_time__day + ) subq_8 + ) subq_9 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_13.metric_time__day + , subq_13.max_booking_value + FROM ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , MAX(subq_12.max_booking_value) AS max_booking_value + FROM ( + -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.max_booking_value + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.metric_time__day + ) subq_13 + ) subq_14 + ON + subq_9.metric_time__day = subq_14.metric_time__day + GROUP BY + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) +) subq_15 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 new file mode 100644 index 0000000000..db345ac389 --- /dev/null +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -0,0 +1,58 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , CAST(average_booking_value AS DOUBLE) / CAST(NULLIF(max_booking_value, 0) AS DOUBLE) AS instant_booking_fraction_of_max_value +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.average_booking_value) AS average_booking_value + , MAX(subq_28.max_booking_value) AS max_booking_value + FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + metric_time__day + , AVG(average_booking_value) AS average_booking_value + FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + metric_time__day + , booking__is_instant + , average_booking_value + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , is_instant AS booking__is_instant + , booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_17 + WHERE booking__is_instant + ) subq_19 + WHERE booking__is_instant + GROUP BY + metric_time__day + ) subq_23 + FULL OUTER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , MAX(booking_value) AS max_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_28 + ON + subq_23.metric_time__day = subq_28.metric_time__day + GROUP BY + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) +) subq_29 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 c3a78081ba..e1c91ce539 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,249 +1,48 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_12.user__home_state_latest + , subq_12.listings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_11.user__home_state_latest + , SUM(subq_11.listings) AS listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant'] + -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_10.user__home_state_latest + , subq_10.listings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.bookings + subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.user__home_state_latest + , subq_9.listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.bookings + subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.user__home_state_latest + , subq_8.listings FROM ( -- Join Standard Outputs SELECT - subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_5.capacity_latest AS listing__capacity_latest - , subq_2.bookings AS bookings + subq_5.user AS user + , subq_5.listing__is_lux_latest AS listing__is_lux_latest + , subq_5.listing__capacity_latest AS listing__capacity_latest + , subq_7.home_state_latest AS user__home_state_latest + , subq_5.listings AS listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_4.user + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'capacity_latest', 'listing', 'listing'] - SELECT - subq_4.listing - , subq_4.is_lux_latest - , subq_4.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + -- Constrain Output with WHERE SELECT subq_3.ds__day , subq_3.ds__week @@ -289,17 +88,17 @@ FROM ( , subq_3.listing__created_at__extract_day , subq_3.listing__created_at__extract_dow , subq_3.listing__created_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy , subq_3.listing , subq_3.user , subq_3.listing__user @@ -313,75 +112,183 @@ FROM ( , subq_3.largest_listing , subq_3.smallest_listing FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + SELECT + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 ) subq_3 + WHERE listing__is_lux_latest OR listing__capacity_latest > 4 ) subq_4 ) subq_5 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_6.user + , subq_6.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' + SELECT + DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_28000.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy + , users_latest_src_28000.home_state_latest + , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day + , EXTRACT(dayofweekiso FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , users_latest_src_28000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_28000 + ) subq_6 + ) subq_7 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_5.user = subq_7.user + ) subq_8 + ) subq_9 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_8 - ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_11.user__home_state_latest +) subq_12 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 98cc26bb70..76b28308ab 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 @@ -1,33 +1,43 @@ -- Constrain Output with WHERE --- Pass Only Elements: ['bookings', 'booking__is_instant'] +-- Pass Only Elements: ['listings', 'user__home_state_latest'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - booking__is_instant - , SUM(bookings) AS bookings + user__home_state_latest + , SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_13.bookings AS bookings + subq_16.listing__is_lux_latest AS listing__is_lux_latest + , subq_16.listing__capacity_latest AS listing__capacity_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_16.listings AS listings FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Constrain Output with WHERE + -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - listing_id AS listing - , is_instant AS booking__is_instant - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + subq_14.user + , listing__is_lux_latest + , listing__capacity_latest + , listings + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' + SELECT + user_id AS user + , is_lux AS listing__is_lux_latest + , capacity AS listing__capacity_latest + , 1 AS listings + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_14 + WHERE listing__is_lux_latest OR listing__capacity_latest > 4 + ) subq_16 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28000 + ***************************.dim_users_latest users_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_16.user = users_latest_src_28000.user_id +) subq_20 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY - booking__is_instant + user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 0b87608c26..0c3cde2ebe 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_17.listing__country_latest - , subq_17.bookings + subq_13.listing__country_latest + , subq_13.bookings FROM ( -- Aggregate Measures SELECT - subq_16.listing__country_latest - , SUM(subq_16.bookings) AS bookings + subq_12.listing__country_latest + , SUM(subq_12.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_15.listing__country_latest - , subq_15.bookings + subq_11.listing__country_latest + , subq_11.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_14.booking__is_instant - , subq_14.listing__country_latest - , subq_14.bookings + subq_10.booking__is_instant + , subq_10.listing__country_latest + , subq_10.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant - , subq_13.listing__country_latest - , subq_13.bookings + subq_9.booking__is_instant + , subq_9.listing__country_latest + , subq_9.bookings FROM ( -- Join Standard Outputs SELECT - subq_9.listing AS listing - , subq_9.booking__is_instant AS booking__is_instant - , subq_12.country_latest AS listing__country_latest - , subq_9.bookings AS bookings + subq_5.listing AS listing + , subq_5.booking__is_instant AS booking__is_instant + , subq_8.country_latest AS listing__country_latest + , subq_5.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_8.listing - , subq_8.booking__is_instant - , subq_8.bookings + subq_4.listing + , subq_4.booking__is_instant + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -331,86 +331,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_11.listing - , subq_11.country_latest + subq_7.listing + , subq_7.country_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.created_at__day - , subq_10.created_at__week - , subq_10.created_at__month - , subq_10.created_at__quarter - , subq_10.created_at__year - , subq_10.created_at__extract_year - , subq_10.created_at__extract_quarter - , subq_10.created_at__extract_month - , subq_10.created_at__extract_day - , subq_10.created_at__extract_dow - , subq_10.created_at__extract_doy - , subq_10.listing__ds__day - , subq_10.listing__ds__week - , subq_10.listing__ds__month - , subq_10.listing__ds__quarter - , subq_10.listing__ds__year - , subq_10.listing__ds__extract_year - , subq_10.listing__ds__extract_quarter - , subq_10.listing__ds__extract_month - , subq_10.listing__ds__extract_day - , subq_10.listing__ds__extract_dow - , subq_10.listing__ds__extract_doy - , subq_10.listing__created_at__day - , subq_10.listing__created_at__week - , subq_10.listing__created_at__month - , subq_10.listing__created_at__quarter - , subq_10.listing__created_at__year - , subq_10.listing__created_at__extract_year - , subq_10.listing__created_at__extract_quarter - , subq_10.listing__created_at__extract_month - , subq_10.listing__created_at__extract_day - , subq_10.listing__created_at__extract_dow - , subq_10.listing__created_at__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.listing - , subq_10.user - , subq_10.listing__user - , subq_10.country_latest - , subq_10.is_lux_latest - , subq_10.capacity_latest - , subq_10.listing__country_latest - , subq_10.listing__is_lux_latest - , subq_10.listing__capacity_latest - , subq_10.listings - , subq_10.largest_listing - , subq_10.smallest_listing + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.created_at__day + , subq_6.created_at__week + , subq_6.created_at__month + , subq_6.created_at__quarter + , subq_6.created_at__year + , subq_6.created_at__extract_year + , subq_6.created_at__extract_quarter + , subq_6.created_at__extract_month + , subq_6.created_at__extract_day + , subq_6.created_at__extract_dow + , subq_6.created_at__extract_doy + , subq_6.listing__ds__day + , subq_6.listing__ds__week + , subq_6.listing__ds__month + , subq_6.listing__ds__quarter + , subq_6.listing__ds__year + , subq_6.listing__ds__extract_year + , subq_6.listing__ds__extract_quarter + , subq_6.listing__ds__extract_month + , subq_6.listing__ds__extract_day + , subq_6.listing__ds__extract_dow + , subq_6.listing__ds__extract_doy + , subq_6.listing__created_at__day + , subq_6.listing__created_at__week + , subq_6.listing__created_at__month + , subq_6.listing__created_at__quarter + , subq_6.listing__created_at__year + , subq_6.listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month + , subq_6.listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.user + , subq_6.listing__user + , subq_6.country_latest + , subq_6.is_lux_latest + , subq_6.capacity_latest + , subq_6.listing__country_latest + , subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.listings + , subq_6.largest_listing + , subq_6.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -471,16 +471,16 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_9.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_5.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE booking__is_instant - ) subq_15 - ) subq_16 + ) subq_11 + ) subq_12 GROUP BY - subq_16.listing__country_latest -) subq_17 + subq_12.listing__country_latest +) subq_13 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 b0a46663de..e1420879c4 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_21.booking__is_instant AS booking__is_instant + subq_17.booking__is_instant AS booking__is_instant , listings_latest_src_28000.country AS listing__country_latest - , subq_21.bookings AS bookings + , subq_17.bookings AS bookings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] @@ -27,14 +27,14 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_21.listing = listings_latest_src_28000.listing_id -) subq_26 + subq_17.listing = listings_latest_src_28000.listing_id +) subq_22 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_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 new file mode 100644 index 0000000000..c939f6d0df --- /dev/null +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -0,0 +1,563 @@ +-- Compute Metrics via Expressions +SELECT + subq_15.metric_time__day + , CAST(subq_15.average_booking_value AS DOUBLE) / CAST(NULLIF(subq_15.max_booking_value, 0) AS DOUBLE) AS instant_booking_fraction_of_max_value +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) AS metric_time__day + , MAX(subq_9.average_booking_value) AS average_booking_value + , MAX(subq_14.max_booking_value) AS max_booking_value + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_8.metric_time__day + , subq_8.average_booking_value + FROM ( + -- Aggregate Measures + SELECT + subq_7.metric_time__day + , AVG(subq_7.average_booking_value) AS average_booking_value + FROM ( + -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] + SELECT + subq_6.metric_time__day + , subq_6.average_booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.average_booking_value + FROM ( + -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.average_booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + WHERE booking__is_instant + ) subq_4 + ) subq_5 + WHERE booking__is_instant + ) subq_6 + ) subq_7 + GROUP BY + subq_7.metric_time__day + ) subq_8 + ) subq_9 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_13.metric_time__day + , subq_13.max_booking_value + FROM ( + -- Aggregate Measures + SELECT + subq_12.metric_time__day + , MAX(subq_12.max_booking_value) AS max_booking_value + FROM ( + -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] + SELECT + subq_11.metric_time__day + , subq_11.max_booking_value + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + ) subq_12 + GROUP BY + subq_12.metric_time__day + ) subq_13 + ) subq_14 + ON + subq_9.metric_time__day = subq_14.metric_time__day + GROUP BY + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) +) subq_15 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 new file mode 100644 index 0000000000..db345ac389 --- /dev/null +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -0,0 +1,58 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__day + , CAST(average_booking_value AS DOUBLE) / CAST(NULLIF(max_booking_value, 0) AS DOUBLE) AS instant_booking_fraction_of_max_value +FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.average_booking_value) AS average_booking_value + , MAX(subq_28.max_booking_value) AS max_booking_value + FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + metric_time__day + , AVG(average_booking_value) AS average_booking_value + FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + metric_time__day + , booking__is_instant + , average_booking_value + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , is_instant AS booking__is_instant + , booking_value AS average_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_17 + WHERE booking__is_instant + ) subq_19 + WHERE booking__is_instant + GROUP BY + metric_time__day + ) subq_23 + FULL OUTER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , MAX(booking_value) AS max_booking_value + FROM ***************************.fct_bookings bookings_source_src_28000 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_28 + ON + subq_23.metric_time__day = subq_28.metric_time__day + GROUP BY + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) +) subq_29 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 02f3269db7..15d9663ea3 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,249 +1,48 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_12.user__home_state_latest + , subq_12.listings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_11.user__home_state_latest + , SUM(subq_11.listings) AS listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant'] + -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_10.user__home_state_latest + , subq_10.listings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.bookings + subq_9.listing__is_lux_latest + , subq_9.listing__capacity_latest + , subq_9.user__home_state_latest + , subq_9.listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.bookings + subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.user__home_state_latest + , subq_8.listings FROM ( -- Join Standard Outputs SELECT - subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_5.capacity_latest AS listing__capacity_latest - , subq_2.bookings AS bookings + subq_5.user AS user + , subq_5.listing__is_lux_latest AS listing__is_lux_latest + , subq_5.listing__capacity_latest AS listing__capacity_latest + , subq_7.home_state_latest AS user__home_state_latest + , subq_5.listings AS listings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_4.user + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'capacity_latest', 'listing', 'listing'] - SELECT - subq_4.listing - , subq_4.is_lux_latest - , subq_4.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + -- Constrain Output with WHERE SELECT subq_3.ds__day , subq_3.ds__week @@ -289,17 +88,17 @@ FROM ( , subq_3.listing__created_at__extract_day , subq_3.listing__created_at__extract_dow , subq_3.listing__created_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy , subq_3.listing , subq_3.user , subq_3.listing__user @@ -313,75 +112,183 @@ FROM ( , subq_3.largest_listing , subq_3.smallest_listing FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + SELECT + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 ) subq_3 + WHERE listing__is_lux_latest OR listing__capacity_latest > 4 ) subq_4 ) subq_5 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_6.user + , subq_6.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' + SELECT + DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28000.ds) AS ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy + , users_latest_src_28000.home_state_latest + , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day + , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week + , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month + , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter + , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year + , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year + , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter + , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month + , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow + , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , users_latest_src_28000.user_id AS user + FROM ***************************.dim_users_latest users_latest_src_28000 + ) subq_6 + ) subq_7 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_5.user = subq_7.user + ) subq_8 + ) subq_9 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_8 - ) subq_9 + ) subq_10 + ) subq_11 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_11.user__home_state_latest +) subq_12 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 98cc26bb70..76b28308ab 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 @@ -1,33 +1,43 @@ -- Constrain Output with WHERE --- Pass Only Elements: ['bookings', 'booking__is_instant'] +-- Pass Only Elements: ['listings', 'user__home_state_latest'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - booking__is_instant - , SUM(bookings) AS bookings + user__home_state_latest + , SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_13.bookings AS bookings + subq_16.listing__is_lux_latest AS listing__is_lux_latest + , subq_16.listing__capacity_latest AS listing__capacity_latest + , users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_16.listings AS listings FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Constrain Output with WHERE + -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT - listing_id AS listing - , is_instant AS booking__is_instant - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + subq_14.user + , listing__is_lux_latest + , listing__capacity_latest + , listings + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' + SELECT + user_id AS user + , is_lux AS listing__is_lux_latest + , capacity AS listing__capacity_latest + , 1 AS listings + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_14 + WHERE listing__is_lux_latest OR listing__capacity_latest > 4 + ) subq_16 LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28000 + ***************************.dim_users_latest users_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_16.user = users_latest_src_28000.user_id +) subq_20 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY - booking__is_instant + user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 1a9c203c63..f257d9cbc3 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_17.listing__country_latest - , subq_17.bookings + subq_13.listing__country_latest + , subq_13.bookings FROM ( -- Aggregate Measures SELECT - subq_16.listing__country_latest - , SUM(subq_16.bookings) AS bookings + subq_12.listing__country_latest + , SUM(subq_12.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_15.listing__country_latest - , subq_15.bookings + subq_11.listing__country_latest + , subq_11.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_14.booking__is_instant - , subq_14.listing__country_latest - , subq_14.bookings + subq_10.booking__is_instant + , subq_10.listing__country_latest + , subq_10.bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant - , subq_13.listing__country_latest - , subq_13.bookings + subq_9.booking__is_instant + , subq_9.listing__country_latest + , subq_9.bookings FROM ( -- Join Standard Outputs SELECT - subq_9.listing AS listing - , subq_9.booking__is_instant AS booking__is_instant - , subq_12.country_latest AS listing__country_latest - , subq_9.bookings AS bookings + subq_5.listing AS listing + , subq_5.booking__is_instant AS booking__is_instant + , subq_8.country_latest AS listing__country_latest + , subq_5.bookings AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT - subq_8.listing - , subq_8.booking__is_instant - , subq_8.bookings + subq_4.listing + , subq_4.booking__is_instant + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -331,86 +331,86 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_11.listing - , subq_11.country_latest + subq_7.listing + , subq_7.country_latest FROM ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.created_at__day - , subq_10.created_at__week - , subq_10.created_at__month - , subq_10.created_at__quarter - , subq_10.created_at__year - , subq_10.created_at__extract_year - , subq_10.created_at__extract_quarter - , subq_10.created_at__extract_month - , subq_10.created_at__extract_day - , subq_10.created_at__extract_dow - , subq_10.created_at__extract_doy - , subq_10.listing__ds__day - , subq_10.listing__ds__week - , subq_10.listing__ds__month - , subq_10.listing__ds__quarter - , subq_10.listing__ds__year - , subq_10.listing__ds__extract_year - , subq_10.listing__ds__extract_quarter - , subq_10.listing__ds__extract_month - , subq_10.listing__ds__extract_day - , subq_10.listing__ds__extract_dow - , subq_10.listing__ds__extract_doy - , subq_10.listing__created_at__day - , subq_10.listing__created_at__week - , subq_10.listing__created_at__month - , subq_10.listing__created_at__quarter - , subq_10.listing__created_at__year - , subq_10.listing__created_at__extract_year - , subq_10.listing__created_at__extract_quarter - , subq_10.listing__created_at__extract_month - , subq_10.listing__created_at__extract_day - , subq_10.listing__created_at__extract_dow - , subq_10.listing__created_at__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.listing - , subq_10.user - , subq_10.listing__user - , subq_10.country_latest - , subq_10.is_lux_latest - , subq_10.capacity_latest - , subq_10.listing__country_latest - , subq_10.listing__is_lux_latest - , subq_10.listing__capacity_latest - , subq_10.listings - , subq_10.largest_listing - , subq_10.smallest_listing + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.created_at__day + , subq_6.created_at__week + , subq_6.created_at__month + , subq_6.created_at__quarter + , subq_6.created_at__year + , subq_6.created_at__extract_year + , subq_6.created_at__extract_quarter + , subq_6.created_at__extract_month + , subq_6.created_at__extract_day + , subq_6.created_at__extract_dow + , subq_6.created_at__extract_doy + , subq_6.listing__ds__day + , subq_6.listing__ds__week + , subq_6.listing__ds__month + , subq_6.listing__ds__quarter + , subq_6.listing__ds__year + , subq_6.listing__ds__extract_year + , subq_6.listing__ds__extract_quarter + , subq_6.listing__ds__extract_month + , subq_6.listing__ds__extract_day + , subq_6.listing__ds__extract_dow + , subq_6.listing__ds__extract_doy + , subq_6.listing__created_at__day + , subq_6.listing__created_at__week + , subq_6.listing__created_at__month + , subq_6.listing__created_at__quarter + , subq_6.listing__created_at__year + , subq_6.listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month + , subq_6.listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.user + , subq_6.listing__user + , subq_6.country_latest + , subq_6.is_lux_latest + , subq_6.capacity_latest + , subq_6.listing__country_latest + , subq_6.listing__is_lux_latest + , subq_6.listing__capacity_latest + , subq_6.listings + , subq_6.largest_listing + , subq_6.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -471,16 +471,16 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_6 + ) subq_7 + ) subq_8 ON - subq_9.listing = subq_12.listing - ) subq_13 - ) subq_14 + subq_5.listing = subq_8.listing + ) subq_9 + ) subq_10 WHERE booking__is_instant - ) subq_15 - ) subq_16 + ) subq_11 + ) subq_12 GROUP BY - subq_16.listing__country_latest -) subq_17 + subq_12.listing__country_latest +) subq_13 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/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 b0a46663de..e1420879c4 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_21.booking__is_instant AS booking__is_instant + subq_17.booking__is_instant AS booking__is_instant , listings_latest_src_28000.country AS listing__country_latest - , subq_21.bookings AS bookings + , subq_17.bookings AS bookings FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] @@ -27,14 +27,14 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_15 WHERE booking__is_instant - ) subq_21 + ) subq_17 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_21.listing = listings_latest_src_28000.listing_id -) subq_26 + subq_17.listing = listings_latest_src_28000.listing_id +) subq_22 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0.sql index f699c35c7d..64eedb3232 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0.sql @@ -1,195 +1,134 @@ -- Order By ['listing__country_latest'] Limit 100 SELECT - subq_5.listing__country_latest + subq_2.listing__country_latest FROM ( -- Pass Only Elements: ['listing__country_latest',] SELECT - subq_4.listing__country_latest + subq_1.listing__country_latest FROM ( -- Constrain Output with WHERE SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.created_at__day - , subq_3.created_at__week - , subq_3.created_at__month - , subq_3.created_at__quarter - , subq_3.created_at__year - , subq_3.created_at__extract_year - , subq_3.created_at__extract_quarter - , subq_3.created_at__extract_month - , subq_3.created_at__extract_day - , subq_3.created_at__extract_dow - , subq_3.created_at__extract_doy - , subq_3.listing__ds__day - , subq_3.listing__ds__week - , subq_3.listing__ds__month - , subq_3.listing__ds__quarter - , subq_3.listing__ds__year - , subq_3.listing__ds__extract_year - , subq_3.listing__ds__extract_quarter - , subq_3.listing__ds__extract_month - , subq_3.listing__ds__extract_day - , subq_3.listing__ds__extract_dow - , subq_3.listing__ds__extract_doy - , subq_3.listing__created_at__day - , subq_3.listing__created_at__week - , subq_3.listing__created_at__month - , subq_3.listing__created_at__quarter - , subq_3.listing__created_at__year - , subq_3.listing__created_at__extract_year - , subq_3.listing__created_at__extract_quarter - , subq_3.listing__created_at__extract_month - , subq_3.listing__created_at__extract_day - , subq_3.listing__created_at__extract_dow - , subq_3.listing__created_at__extract_doy - , subq_3.listing - , subq_3.user - , subq_3.listing__user - , subq_3.country_latest - , subq_3.is_lux_latest - , subq_3.capacity_latest - , subq_3.listing__country_latest - , subq_3.listing__is_lux_latest - , subq_3.listing__capacity_latest - , subq_3.listings - , subq_3.largest_listing - , subq_3.smallest_listing + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_2.ds__day - , subq_2.ds__week - , subq_2.ds__month - , subq_2.ds__quarter - , subq_2.ds__year - , subq_2.ds__extract_year - , subq_2.ds__extract_quarter - , subq_2.ds__extract_month - , subq_2.ds__extract_day - , subq_2.ds__extract_dow - , subq_2.ds__extract_doy - , subq_2.created_at__day - , subq_2.created_at__week - , subq_2.created_at__month - , subq_2.created_at__quarter - , subq_2.created_at__year - , subq_2.created_at__extract_year - , subq_2.created_at__extract_quarter - , subq_2.created_at__extract_month - , subq_2.created_at__extract_day - , subq_2.created_at__extract_dow - , subq_2.created_at__extract_doy - , subq_2.listing__ds__day - , subq_2.listing__ds__week - , subq_2.listing__ds__month - , subq_2.listing__ds__quarter - , subq_2.listing__ds__year - , subq_2.listing__ds__extract_year - , subq_2.listing__ds__extract_quarter - , subq_2.listing__ds__extract_month - , subq_2.listing__ds__extract_day - , subq_2.listing__ds__extract_dow - , subq_2.listing__ds__extract_doy - , subq_2.listing__created_at__day - , subq_2.listing__created_at__week - , subq_2.listing__created_at__month - , subq_2.listing__created_at__quarter - , subq_2.listing__created_at__year - , subq_2.listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month - , subq_2.listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy - , subq_2.listing - , subq_2.user - , subq_2.listing__user - , subq_2.country_latest - , subq_2.is_lux_latest - , subq_2.capacity_latest - , subq_2.listing__country_latest - , subq_2.listing__is_lux_latest - , subq_2.listing__capacity_latest - , subq_2.listings - , subq_2.largest_listing - , subq_2.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS listing__ds__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS listing__created_at__extract_dow - , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 - WHERE listing__country_latest = 'us' - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS listing__ds__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATE_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATE_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATE_TRUNC(listings_latest_src_28000.created_at, year) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , IF(EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM listings_latest_src_28000.created_at) - 1) AS listing__created_at__extract_dow + , EXTRACT(dayofyear FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 WHERE listing__country_latest = 'us' - ) subq_4 + ) subq_1 GROUP BY listing__country_latest -) subq_5 -ORDER BY subq_5.listing__country_latest DESC +) subq_2 +ORDER BY subq_2.listing__country_latest DESC LIMIT 100 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0_optimized.sql index 76e6591b6c..1653ada5bd 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0_optimized.sql @@ -4,17 +4,11 @@ SELECT listing__country_latest FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - listing__country_latest - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - WHERE listing__country_latest = 'us' -) subq_7 + country AS listing__country_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_3 WHERE listing__country_latest = 'us' GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 405416b013..27f19d6c82 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_19.metric_time__day - , CAST(subq_19.booking_value_with_is_instant_constraint AS FLOAT64) / CAST(NULLIF(subq_19.booking_value, 0) AS FLOAT64) AS instant_booking_value_ratio + 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 FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day - , MAX(subq_13.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_18.booking_value) AS booking_value + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) AS metric_time__day + , MAX(subq_9.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_14.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.booking_value AS booking_value_with_is_instant_constraint + subq_8.metric_time__day + , subq_8.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.booking_value) AS booking_value + subq_7.metric_time__day + , SUM(subq_7.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_6.metric_time__day + , subq_6.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.booking_value + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking__is_instant - , subq_8.booking_value + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -329,134 +329,134 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 WHERE booking__is_instant - ) subq_10 - ) subq_11 + ) subq_6 + ) subq_7 GROUP BY metric_time__day - ) subq_12 - ) subq_13 + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day - , subq_17.booking_value + subq_13.metric_time__day + , subq_13.booking_value FROM ( -- Aggregate Measures SELECT - subq_16.metric_time__day - , SUM(subq_16.booking_value) AS booking_value + subq_12.metric_time__day + , SUM(subq_12.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_15.metric_time__day - , subq_15.booking_value + subq_11.metric_time__day + , subq_11.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_14.ds__day - , subq_14.ds__week - , subq_14.ds__month - , subq_14.ds__quarter - , subq_14.ds__year - , subq_14.ds__extract_year - , subq_14.ds__extract_quarter - , subq_14.ds__extract_month - , subq_14.ds__extract_day - , subq_14.ds__extract_dow - , subq_14.ds__extract_doy - , subq_14.ds_partitioned__day - , subq_14.ds_partitioned__week - , subq_14.ds_partitioned__month - , subq_14.ds_partitioned__quarter - , subq_14.ds_partitioned__year - , subq_14.ds_partitioned__extract_year - , subq_14.ds_partitioned__extract_quarter - , subq_14.ds_partitioned__extract_month - , subq_14.ds_partitioned__extract_day - , subq_14.ds_partitioned__extract_dow - , subq_14.ds_partitioned__extract_doy - , subq_14.paid_at__day - , subq_14.paid_at__week - , subq_14.paid_at__month - , subq_14.paid_at__quarter - , subq_14.paid_at__year - , subq_14.paid_at__extract_year - , subq_14.paid_at__extract_quarter - , subq_14.paid_at__extract_month - , subq_14.paid_at__extract_day - , subq_14.paid_at__extract_dow - , subq_14.paid_at__extract_doy - , subq_14.booking__ds__day - , subq_14.booking__ds__week - , subq_14.booking__ds__month - , subq_14.booking__ds__quarter - , subq_14.booking__ds__year - , subq_14.booking__ds__extract_year - , subq_14.booking__ds__extract_quarter - , subq_14.booking__ds__extract_month - , subq_14.booking__ds__extract_day - , subq_14.booking__ds__extract_dow - , subq_14.booking__ds__extract_doy - , subq_14.booking__ds_partitioned__day - , subq_14.booking__ds_partitioned__week - , subq_14.booking__ds_partitioned__month - , subq_14.booking__ds_partitioned__quarter - , subq_14.booking__ds_partitioned__year - , subq_14.booking__ds_partitioned__extract_year - , subq_14.booking__ds_partitioned__extract_quarter - , subq_14.booking__ds_partitioned__extract_month - , subq_14.booking__ds_partitioned__extract_day - , subq_14.booking__ds_partitioned__extract_dow - , subq_14.booking__ds_partitioned__extract_doy - , subq_14.booking__paid_at__day - , subq_14.booking__paid_at__week - , subq_14.booking__paid_at__month - , subq_14.booking__paid_at__quarter - , subq_14.booking__paid_at__year - , subq_14.booking__paid_at__extract_year - , subq_14.booking__paid_at__extract_quarter - , subq_14.booking__paid_at__extract_month - , subq_14.booking__paid_at__extract_day - , subq_14.booking__paid_at__extract_dow - , subq_14.booking__paid_at__extract_doy - , subq_14.ds__day AS metric_time__day - , subq_14.ds__week AS metric_time__week - , subq_14.ds__month AS metric_time__month - , subq_14.ds__quarter AS metric_time__quarter - , subq_14.ds__year AS metric_time__year - , subq_14.ds__extract_year AS metric_time__extract_year - , subq_14.ds__extract_quarter AS metric_time__extract_quarter - , subq_14.ds__extract_month AS metric_time__extract_month - , subq_14.ds__extract_day AS metric_time__extract_day - , subq_14.ds__extract_dow AS metric_time__extract_dow - , subq_14.ds__extract_doy AS metric_time__extract_doy - , subq_14.listing - , subq_14.guest - , subq_14.host - , subq_14.booking__listing - , subq_14.booking__guest - , subq_14.booking__host - , subq_14.is_instant - , subq_14.booking__is_instant - , subq_14.bookings - , subq_14.instant_bookings - , subq_14.booking_value - , subq_14.max_booking_value - , subq_14.min_booking_value - , subq_14.bookers - , subq_14.average_booking_value - , subq_14.referred_bookings - , subq_14.median_booking_value - , subq_14.booking_value_p99 - , subq_14.discrete_booking_value_p99 - , subq_14.approximate_continuous_booking_value_p99 - , subq_14.approximate_discrete_booking_value_p99 + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -549,15 +549,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 GROUP BY metric_time__day - ) subq_17 - ) subq_18 + ) subq_13 + ) subq_14 ON - subq_13.metric_time__day = subq_18.metric_time__day + subq_9.metric_time__day = subq_14.metric_time__day GROUP BY metric_time__day -) subq_19 +) subq_15 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 899f5800d3..1d91f3f892 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_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_27.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_32.booking_value) AS booking_value + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -31,13 +31,13 @@ FROM ( , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_21 + ) subq_17 WHERE booking__is_instant - ) subq_23 + ) subq_19 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_27 + ) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -50,9 +50,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY metric_time__day - ) subq_32 + ) subq_28 ON - subq_27.metric_time__day = subq_32.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY metric_time__day -) subq_33 +) subq_29 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 a27d1af961..eea0a41878 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_13.metric_time__day + subq_9.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.bookings AS delayed_bookings + subq_8.metric_time__day + , subq_8.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.bookings) AS bookings + subq_7.metric_time__day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_6.metric_time__day + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.bookings + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking__is_instant - , subq_8.bookings + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -323,15 +323,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE NOT booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 WHERE NOT booking__is_instant - ) subq_10 - ) subq_11 + ) subq_6 + ) subq_7 GROUP BY metric_time__day - ) subq_12 -) subq_13 + ) subq_8 +) subq_9 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 f383ad08b9..98e046daea 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_15 + ) subq_11 WHERE NOT booking__is_instant - ) subq_17 + ) subq_13 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_21 +) subq_17 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0.sql index ec223f9e50..e9ee0c5d30 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0.sql @@ -1,195 +1,134 @@ -- Order By ['listing__country_latest'] Limit 100 SELECT - subq_5.listing__country_latest + subq_2.listing__country_latest FROM ( -- Pass Only Elements: ['listing__country_latest',] SELECT - subq_4.listing__country_latest + subq_1.listing__country_latest FROM ( -- Constrain Output with WHERE SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.created_at__day - , subq_3.created_at__week - , subq_3.created_at__month - , subq_3.created_at__quarter - , subq_3.created_at__year - , subq_3.created_at__extract_year - , subq_3.created_at__extract_quarter - , subq_3.created_at__extract_month - , subq_3.created_at__extract_day - , subq_3.created_at__extract_dow - , subq_3.created_at__extract_doy - , subq_3.listing__ds__day - , subq_3.listing__ds__week - , subq_3.listing__ds__month - , subq_3.listing__ds__quarter - , subq_3.listing__ds__year - , subq_3.listing__ds__extract_year - , subq_3.listing__ds__extract_quarter - , subq_3.listing__ds__extract_month - , subq_3.listing__ds__extract_day - , subq_3.listing__ds__extract_dow - , subq_3.listing__ds__extract_doy - , subq_3.listing__created_at__day - , subq_3.listing__created_at__week - , subq_3.listing__created_at__month - , subq_3.listing__created_at__quarter - , subq_3.listing__created_at__year - , subq_3.listing__created_at__extract_year - , subq_3.listing__created_at__extract_quarter - , subq_3.listing__created_at__extract_month - , subq_3.listing__created_at__extract_day - , subq_3.listing__created_at__extract_dow - , subq_3.listing__created_at__extract_doy - , subq_3.listing - , subq_3.user - , subq_3.listing__user - , subq_3.country_latest - , subq_3.is_lux_latest - , subq_3.capacity_latest - , subq_3.listing__country_latest - , subq_3.listing__is_lux_latest - , subq_3.listing__capacity_latest - , subq_3.listings - , subq_3.largest_listing - , subq_3.smallest_listing + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_2.ds__day - , subq_2.ds__week - , subq_2.ds__month - , subq_2.ds__quarter - , subq_2.ds__year - , subq_2.ds__extract_year - , subq_2.ds__extract_quarter - , subq_2.ds__extract_month - , subq_2.ds__extract_day - , subq_2.ds__extract_dow - , subq_2.ds__extract_doy - , subq_2.created_at__day - , subq_2.created_at__week - , subq_2.created_at__month - , subq_2.created_at__quarter - , subq_2.created_at__year - , subq_2.created_at__extract_year - , subq_2.created_at__extract_quarter - , subq_2.created_at__extract_month - , subq_2.created_at__extract_day - , subq_2.created_at__extract_dow - , subq_2.created_at__extract_doy - , subq_2.listing__ds__day - , subq_2.listing__ds__week - , subq_2.listing__ds__month - , subq_2.listing__ds__quarter - , subq_2.listing__ds__year - , subq_2.listing__ds__extract_year - , subq_2.listing__ds__extract_quarter - , subq_2.listing__ds__extract_month - , subq_2.listing__ds__extract_day - , subq_2.listing__ds__extract_dow - , subq_2.listing__ds__extract_doy - , subq_2.listing__created_at__day - , subq_2.listing__created_at__week - , subq_2.listing__created_at__month - , subq_2.listing__created_at__quarter - , subq_2.listing__created_at__year - , subq_2.listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month - , subq_2.listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy - , subq_2.listing - , subq_2.user - , subq_2.listing__user - , subq_2.country_latest - , subq_2.is_lux_latest - , subq_2.capacity_latest - , subq_2.listing__country_latest - , subq_2.listing__is_lux_latest - , subq_2.listing__capacity_latest - , subq_2.listings - , subq_2.largest_listing - , subq_2.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 - WHERE listing__country_latest = 'us' - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 WHERE listing__country_latest = 'us' - ) subq_4 + ) subq_1 GROUP BY - subq_4.listing__country_latest -) subq_5 -ORDER BY subq_5.listing__country_latest DESC + subq_1.listing__country_latest +) subq_2 +ORDER BY subq_2.listing__country_latest DESC LIMIT 100 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0_optimized.sql index 76e6591b6c..1653ada5bd 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_distinct_values__plan0_optimized.sql @@ -4,17 +4,11 @@ SELECT listing__country_latest FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - listing__country_latest - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - WHERE listing__country_latest = 'us' -) subq_7 + country AS listing__country_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_3 WHERE listing__country_latest = 'us' GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 ddc3216f51..98239358a2 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_19.metric_time__day - , CAST(subq_19.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_19.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio + subq_15.metric_time__day + , CAST(subq_15.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_15.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day - , MAX(subq_13.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_18.booking_value) AS booking_value + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) AS metric_time__day + , MAX(subq_9.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_14.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.booking_value AS booking_value_with_is_instant_constraint + subq_8.metric_time__day + , subq_8.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.booking_value) AS booking_value + subq_7.metric_time__day + , SUM(subq_7.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_6.metric_time__day + , subq_6.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.booking_value + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking__is_instant - , subq_8.booking_value + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -329,134 +329,134 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 WHERE booking__is_instant - ) subq_10 - ) subq_11 + ) subq_6 + ) subq_7 GROUP BY - subq_11.metric_time__day - ) subq_12 - ) subq_13 + subq_7.metric_time__day + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day - , subq_17.booking_value + subq_13.metric_time__day + , subq_13.booking_value FROM ( -- Aggregate Measures SELECT - subq_16.metric_time__day - , SUM(subq_16.booking_value) AS booking_value + subq_12.metric_time__day + , SUM(subq_12.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_15.metric_time__day - , subq_15.booking_value + subq_11.metric_time__day + , subq_11.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_14.ds__day - , subq_14.ds__week - , subq_14.ds__month - , subq_14.ds__quarter - , subq_14.ds__year - , subq_14.ds__extract_year - , subq_14.ds__extract_quarter - , subq_14.ds__extract_month - , subq_14.ds__extract_day - , subq_14.ds__extract_dow - , subq_14.ds__extract_doy - , subq_14.ds_partitioned__day - , subq_14.ds_partitioned__week - , subq_14.ds_partitioned__month - , subq_14.ds_partitioned__quarter - , subq_14.ds_partitioned__year - , subq_14.ds_partitioned__extract_year - , subq_14.ds_partitioned__extract_quarter - , subq_14.ds_partitioned__extract_month - , subq_14.ds_partitioned__extract_day - , subq_14.ds_partitioned__extract_dow - , subq_14.ds_partitioned__extract_doy - , subq_14.paid_at__day - , subq_14.paid_at__week - , subq_14.paid_at__month - , subq_14.paid_at__quarter - , subq_14.paid_at__year - , subq_14.paid_at__extract_year - , subq_14.paid_at__extract_quarter - , subq_14.paid_at__extract_month - , subq_14.paid_at__extract_day - , subq_14.paid_at__extract_dow - , subq_14.paid_at__extract_doy - , subq_14.booking__ds__day - , subq_14.booking__ds__week - , subq_14.booking__ds__month - , subq_14.booking__ds__quarter - , subq_14.booking__ds__year - , subq_14.booking__ds__extract_year - , subq_14.booking__ds__extract_quarter - , subq_14.booking__ds__extract_month - , subq_14.booking__ds__extract_day - , subq_14.booking__ds__extract_dow - , subq_14.booking__ds__extract_doy - , subq_14.booking__ds_partitioned__day - , subq_14.booking__ds_partitioned__week - , subq_14.booking__ds_partitioned__month - , subq_14.booking__ds_partitioned__quarter - , subq_14.booking__ds_partitioned__year - , subq_14.booking__ds_partitioned__extract_year - , subq_14.booking__ds_partitioned__extract_quarter - , subq_14.booking__ds_partitioned__extract_month - , subq_14.booking__ds_partitioned__extract_day - , subq_14.booking__ds_partitioned__extract_dow - , subq_14.booking__ds_partitioned__extract_doy - , subq_14.booking__paid_at__day - , subq_14.booking__paid_at__week - , subq_14.booking__paid_at__month - , subq_14.booking__paid_at__quarter - , subq_14.booking__paid_at__year - , subq_14.booking__paid_at__extract_year - , subq_14.booking__paid_at__extract_quarter - , subq_14.booking__paid_at__extract_month - , subq_14.booking__paid_at__extract_day - , subq_14.booking__paid_at__extract_dow - , subq_14.booking__paid_at__extract_doy - , subq_14.ds__day AS metric_time__day - , subq_14.ds__week AS metric_time__week - , subq_14.ds__month AS metric_time__month - , subq_14.ds__quarter AS metric_time__quarter - , subq_14.ds__year AS metric_time__year - , subq_14.ds__extract_year AS metric_time__extract_year - , subq_14.ds__extract_quarter AS metric_time__extract_quarter - , subq_14.ds__extract_month AS metric_time__extract_month - , subq_14.ds__extract_day AS metric_time__extract_day - , subq_14.ds__extract_dow AS metric_time__extract_dow - , subq_14.ds__extract_doy AS metric_time__extract_doy - , subq_14.listing - , subq_14.guest - , subq_14.host - , subq_14.booking__listing - , subq_14.booking__guest - , subq_14.booking__host - , subq_14.is_instant - , subq_14.booking__is_instant - , subq_14.bookings - , subq_14.instant_bookings - , subq_14.booking_value - , subq_14.max_booking_value - , subq_14.min_booking_value - , subq_14.bookers - , subq_14.average_booking_value - , subq_14.referred_bookings - , subq_14.median_booking_value - , subq_14.booking_value_p99 - , subq_14.discrete_booking_value_p99 - , subq_14.approximate_continuous_booking_value_p99 - , subq_14.approximate_discrete_booking_value_p99 + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -549,15 +549,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 GROUP BY - subq_16.metric_time__day - ) subq_17 - ) subq_18 + subq_12.metric_time__day + ) subq_13 + ) subq_14 ON - subq_13.metric_time__day = subq_18.metric_time__day + subq_9.metric_time__day = subq_14.metric_time__day GROUP BY - COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) -) subq_19 + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) +) subq_15 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 f0def82955..b3f811ac19 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_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_27.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_32.booking_value) AS booking_value + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -31,13 +31,13 @@ FROM ( , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_21 + ) subq_17 WHERE booking__is_instant - ) subq_23 + ) subq_19 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_27 + ) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -50,9 +50,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_32 + ) subq_28 ON - subq_27.metric_time__day = subq_32.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) +) subq_29 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 2e4a2b5d0a..54cd5f4827 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_13.metric_time__day + subq_9.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.bookings AS delayed_bookings + subq_8.metric_time__day + , subq_8.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.bookings) AS bookings + subq_7.metric_time__day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_6.metric_time__day + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.bookings + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking__is_instant - , subq_8.bookings + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -323,15 +323,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE NOT booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 WHERE NOT booking__is_instant - ) subq_10 - ) subq_11 + ) subq_6 + ) subq_7 GROUP BY - subq_11.metric_time__day - ) subq_12 -) subq_13 + subq_7.metric_time__day + ) subq_8 +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 33436b83b6..31360941eb 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_15 + ) subq_11 WHERE NOT booking__is_instant - ) subq_17 + ) subq_13 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_21 +) subq_17 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0.sql index 4fb1321801..cd3d4c172a 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0.sql @@ -1,195 +1,134 @@ -- Order By ['listing__country_latest'] Limit 100 SELECT - subq_5.listing__country_latest + subq_2.listing__country_latest FROM ( -- Pass Only Elements: ['listing__country_latest',] SELECT - subq_4.listing__country_latest + subq_1.listing__country_latest FROM ( -- Constrain Output with WHERE SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.created_at__day - , subq_3.created_at__week - , subq_3.created_at__month - , subq_3.created_at__quarter - , subq_3.created_at__year - , subq_3.created_at__extract_year - , subq_3.created_at__extract_quarter - , subq_3.created_at__extract_month - , subq_3.created_at__extract_day - , subq_3.created_at__extract_dow - , subq_3.created_at__extract_doy - , subq_3.listing__ds__day - , subq_3.listing__ds__week - , subq_3.listing__ds__month - , subq_3.listing__ds__quarter - , subq_3.listing__ds__year - , subq_3.listing__ds__extract_year - , subq_3.listing__ds__extract_quarter - , subq_3.listing__ds__extract_month - , subq_3.listing__ds__extract_day - , subq_3.listing__ds__extract_dow - , subq_3.listing__ds__extract_doy - , subq_3.listing__created_at__day - , subq_3.listing__created_at__week - , subq_3.listing__created_at__month - , subq_3.listing__created_at__quarter - , subq_3.listing__created_at__year - , subq_3.listing__created_at__extract_year - , subq_3.listing__created_at__extract_quarter - , subq_3.listing__created_at__extract_month - , subq_3.listing__created_at__extract_day - , subq_3.listing__created_at__extract_dow - , subq_3.listing__created_at__extract_doy - , subq_3.listing - , subq_3.user - , subq_3.listing__user - , subq_3.country_latest - , subq_3.is_lux_latest - , subq_3.capacity_latest - , subq_3.listing__country_latest - , subq_3.listing__is_lux_latest - , subq_3.listing__capacity_latest - , subq_3.listings - , subq_3.largest_listing - , subq_3.smallest_listing + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_2.ds__day - , subq_2.ds__week - , subq_2.ds__month - , subq_2.ds__quarter - , subq_2.ds__year - , subq_2.ds__extract_year - , subq_2.ds__extract_quarter - , subq_2.ds__extract_month - , subq_2.ds__extract_day - , subq_2.ds__extract_dow - , subq_2.ds__extract_doy - , subq_2.created_at__day - , subq_2.created_at__week - , subq_2.created_at__month - , subq_2.created_at__quarter - , subq_2.created_at__year - , subq_2.created_at__extract_year - , subq_2.created_at__extract_quarter - , subq_2.created_at__extract_month - , subq_2.created_at__extract_day - , subq_2.created_at__extract_dow - , subq_2.created_at__extract_doy - , subq_2.listing__ds__day - , subq_2.listing__ds__week - , subq_2.listing__ds__month - , subq_2.listing__ds__quarter - , subq_2.listing__ds__year - , subq_2.listing__ds__extract_year - , subq_2.listing__ds__extract_quarter - , subq_2.listing__ds__extract_month - , subq_2.listing__ds__extract_day - , subq_2.listing__ds__extract_dow - , subq_2.listing__ds__extract_doy - , subq_2.listing__created_at__day - , subq_2.listing__created_at__week - , subq_2.listing__created_at__month - , subq_2.listing__created_at__quarter - , subq_2.listing__created_at__year - , subq_2.listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month - , subq_2.listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy - , subq_2.listing - , subq_2.user - , subq_2.listing__user - , subq_2.country_latest - , subq_2.is_lux_latest - , subq_2.capacity_latest - , subq_2.listing__country_latest - , subq_2.listing__is_lux_latest - , subq_2.listing__capacity_latest - , subq_2.listings - , subq_2.largest_listing - , subq_2.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 - WHERE listing__country_latest = 'us' - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 WHERE listing__country_latest = 'us' - ) subq_4 + ) subq_1 GROUP BY - subq_4.listing__country_latest -) subq_5 -ORDER BY subq_5.listing__country_latest DESC + subq_1.listing__country_latest +) subq_2 +ORDER BY subq_2.listing__country_latest DESC LIMIT 100 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0_optimized.sql index 76e6591b6c..1653ada5bd 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_distinct_values__plan0_optimized.sql @@ -4,17 +4,11 @@ SELECT listing__country_latest FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - listing__country_latest - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - WHERE listing__country_latest = 'us' -) subq_7 + country AS listing__country_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_3 WHERE listing__country_latest = 'us' GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 5dd3547c45..fdbdd6f898 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_19.metric_time__day - , CAST(subq_19.booking_value_with_is_instant_constraint AS DOUBLE PRECISION) / CAST(NULLIF(subq_19.booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_value_ratio + 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 FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day - , MAX(subq_13.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_18.booking_value) AS booking_value + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) AS metric_time__day + , MAX(subq_9.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_14.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.booking_value AS booking_value_with_is_instant_constraint + subq_8.metric_time__day + , subq_8.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.booking_value) AS booking_value + subq_7.metric_time__day + , SUM(subq_7.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_6.metric_time__day + , subq_6.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.booking_value + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking__is_instant - , subq_8.booking_value + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -329,134 +329,134 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 WHERE booking__is_instant - ) subq_10 - ) subq_11 + ) subq_6 + ) subq_7 GROUP BY - subq_11.metric_time__day - ) subq_12 - ) subq_13 + subq_7.metric_time__day + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day - , subq_17.booking_value + subq_13.metric_time__day + , subq_13.booking_value FROM ( -- Aggregate Measures SELECT - subq_16.metric_time__day - , SUM(subq_16.booking_value) AS booking_value + subq_12.metric_time__day + , SUM(subq_12.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_15.metric_time__day - , subq_15.booking_value + subq_11.metric_time__day + , subq_11.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_14.ds__day - , subq_14.ds__week - , subq_14.ds__month - , subq_14.ds__quarter - , subq_14.ds__year - , subq_14.ds__extract_year - , subq_14.ds__extract_quarter - , subq_14.ds__extract_month - , subq_14.ds__extract_day - , subq_14.ds__extract_dow - , subq_14.ds__extract_doy - , subq_14.ds_partitioned__day - , subq_14.ds_partitioned__week - , subq_14.ds_partitioned__month - , subq_14.ds_partitioned__quarter - , subq_14.ds_partitioned__year - , subq_14.ds_partitioned__extract_year - , subq_14.ds_partitioned__extract_quarter - , subq_14.ds_partitioned__extract_month - , subq_14.ds_partitioned__extract_day - , subq_14.ds_partitioned__extract_dow - , subq_14.ds_partitioned__extract_doy - , subq_14.paid_at__day - , subq_14.paid_at__week - , subq_14.paid_at__month - , subq_14.paid_at__quarter - , subq_14.paid_at__year - , subq_14.paid_at__extract_year - , subq_14.paid_at__extract_quarter - , subq_14.paid_at__extract_month - , subq_14.paid_at__extract_day - , subq_14.paid_at__extract_dow - , subq_14.paid_at__extract_doy - , subq_14.booking__ds__day - , subq_14.booking__ds__week - , subq_14.booking__ds__month - , subq_14.booking__ds__quarter - , subq_14.booking__ds__year - , subq_14.booking__ds__extract_year - , subq_14.booking__ds__extract_quarter - , subq_14.booking__ds__extract_month - , subq_14.booking__ds__extract_day - , subq_14.booking__ds__extract_dow - , subq_14.booking__ds__extract_doy - , subq_14.booking__ds_partitioned__day - , subq_14.booking__ds_partitioned__week - , subq_14.booking__ds_partitioned__month - , subq_14.booking__ds_partitioned__quarter - , subq_14.booking__ds_partitioned__year - , subq_14.booking__ds_partitioned__extract_year - , subq_14.booking__ds_partitioned__extract_quarter - , subq_14.booking__ds_partitioned__extract_month - , subq_14.booking__ds_partitioned__extract_day - , subq_14.booking__ds_partitioned__extract_dow - , subq_14.booking__ds_partitioned__extract_doy - , subq_14.booking__paid_at__day - , subq_14.booking__paid_at__week - , subq_14.booking__paid_at__month - , subq_14.booking__paid_at__quarter - , subq_14.booking__paid_at__year - , subq_14.booking__paid_at__extract_year - , subq_14.booking__paid_at__extract_quarter - , subq_14.booking__paid_at__extract_month - , subq_14.booking__paid_at__extract_day - , subq_14.booking__paid_at__extract_dow - , subq_14.booking__paid_at__extract_doy - , subq_14.ds__day AS metric_time__day - , subq_14.ds__week AS metric_time__week - , subq_14.ds__month AS metric_time__month - , subq_14.ds__quarter AS metric_time__quarter - , subq_14.ds__year AS metric_time__year - , subq_14.ds__extract_year AS metric_time__extract_year - , subq_14.ds__extract_quarter AS metric_time__extract_quarter - , subq_14.ds__extract_month AS metric_time__extract_month - , subq_14.ds__extract_day AS metric_time__extract_day - , subq_14.ds__extract_dow AS metric_time__extract_dow - , subq_14.ds__extract_doy AS metric_time__extract_doy - , subq_14.listing - , subq_14.guest - , subq_14.host - , subq_14.booking__listing - , subq_14.booking__guest - , subq_14.booking__host - , subq_14.is_instant - , subq_14.booking__is_instant - , subq_14.bookings - , subq_14.instant_bookings - , subq_14.booking_value - , subq_14.max_booking_value - , subq_14.min_booking_value - , subq_14.bookers - , subq_14.average_booking_value - , subq_14.referred_bookings - , subq_14.median_booking_value - , subq_14.booking_value_p99 - , subq_14.discrete_booking_value_p99 - , subq_14.approximate_continuous_booking_value_p99 - , subq_14.approximate_discrete_booking_value_p99 + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -549,15 +549,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 GROUP BY - subq_16.metric_time__day - ) subq_17 - ) subq_18 + subq_12.metric_time__day + ) subq_13 + ) subq_14 ON - subq_13.metric_time__day = subq_18.metric_time__day + subq_9.metric_time__day = subq_14.metric_time__day GROUP BY - COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) -) subq_19 + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) +) subq_15 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 29af02b578..9b1533b73c 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_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_27.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_32.booking_value) AS booking_value + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -31,13 +31,13 @@ FROM ( , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_21 + ) subq_17 WHERE booking__is_instant - ) subq_23 + ) subq_19 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_27 + ) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -50,9 +50,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_32 + ) subq_28 ON - subq_27.metric_time__day = subq_32.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) +) subq_29 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 8e811be580..917ad2f2e1 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_13.metric_time__day + subq_9.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.bookings AS delayed_bookings + subq_8.metric_time__day + , subq_8.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.bookings) AS bookings + subq_7.metric_time__day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_6.metric_time__day + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.bookings + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking__is_instant - , subq_8.bookings + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -323,15 +323,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE NOT booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 WHERE NOT booking__is_instant - ) subq_10 - ) subq_11 + ) subq_6 + ) subq_7 GROUP BY - subq_11.metric_time__day - ) subq_12 -) subq_13 + subq_7.metric_time__day + ) subq_8 +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 33436b83b6..31360941eb 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_15 + ) subq_11 WHERE NOT booking__is_instant - ) subq_17 + ) subq_13 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_21 +) subq_17 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0.sql index 72b8fe6a27..cf9f152551 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0.sql @@ -1,195 +1,134 @@ -- Order By ['listing__country_latest'] Limit 100 SELECT - subq_5.listing__country_latest + subq_2.listing__country_latest FROM ( -- Pass Only Elements: ['listing__country_latest',] SELECT - subq_4.listing__country_latest + subq_1.listing__country_latest FROM ( -- Constrain Output with WHERE SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.created_at__day - , subq_3.created_at__week - , subq_3.created_at__month - , subq_3.created_at__quarter - , subq_3.created_at__year - , subq_3.created_at__extract_year - , subq_3.created_at__extract_quarter - , subq_3.created_at__extract_month - , subq_3.created_at__extract_day - , subq_3.created_at__extract_dow - , subq_3.created_at__extract_doy - , subq_3.listing__ds__day - , subq_3.listing__ds__week - , subq_3.listing__ds__month - , subq_3.listing__ds__quarter - , subq_3.listing__ds__year - , subq_3.listing__ds__extract_year - , subq_3.listing__ds__extract_quarter - , subq_3.listing__ds__extract_month - , subq_3.listing__ds__extract_day - , subq_3.listing__ds__extract_dow - , subq_3.listing__ds__extract_doy - , subq_3.listing__created_at__day - , subq_3.listing__created_at__week - , subq_3.listing__created_at__month - , subq_3.listing__created_at__quarter - , subq_3.listing__created_at__year - , subq_3.listing__created_at__extract_year - , subq_3.listing__created_at__extract_quarter - , subq_3.listing__created_at__extract_month - , subq_3.listing__created_at__extract_day - , subq_3.listing__created_at__extract_dow - , subq_3.listing__created_at__extract_doy - , subq_3.listing - , subq_3.user - , subq_3.listing__user - , subq_3.country_latest - , subq_3.is_lux_latest - , subq_3.capacity_latest - , subq_3.listing__country_latest - , subq_3.listing__is_lux_latest - , subq_3.listing__capacity_latest - , subq_3.listings - , subq_3.largest_listing - , subq_3.smallest_listing + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_2.ds__day - , subq_2.ds__week - , subq_2.ds__month - , subq_2.ds__quarter - , subq_2.ds__year - , subq_2.ds__extract_year - , subq_2.ds__extract_quarter - , subq_2.ds__extract_month - , subq_2.ds__extract_day - , subq_2.ds__extract_dow - , subq_2.ds__extract_doy - , subq_2.created_at__day - , subq_2.created_at__week - , subq_2.created_at__month - , subq_2.created_at__quarter - , subq_2.created_at__year - , subq_2.created_at__extract_year - , subq_2.created_at__extract_quarter - , subq_2.created_at__extract_month - , subq_2.created_at__extract_day - , subq_2.created_at__extract_dow - , subq_2.created_at__extract_doy - , subq_2.listing__ds__day - , subq_2.listing__ds__week - , subq_2.listing__ds__month - , subq_2.listing__ds__quarter - , subq_2.listing__ds__year - , subq_2.listing__ds__extract_year - , subq_2.listing__ds__extract_quarter - , subq_2.listing__ds__extract_month - , subq_2.listing__ds__extract_day - , subq_2.listing__ds__extract_dow - , subq_2.listing__ds__extract_doy - , subq_2.listing__created_at__day - , subq_2.listing__created_at__week - , subq_2.listing__created_at__month - , subq_2.listing__created_at__quarter - , subq_2.listing__created_at__year - , subq_2.listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month - , subq_2.listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy - , subq_2.listing - , subq_2.user - , subq_2.listing__user - , subq_2.country_latest - , subq_2.is_lux_latest - , subq_2.capacity_latest - , subq_2.listing__country_latest - , subq_2.listing__is_lux_latest - , subq_2.listing__capacity_latest - , subq_2.listings - , subq_2.largest_listing - , subq_2.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 - WHERE listing__country_latest = 'us' - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 WHERE listing__country_latest = 'us' - ) subq_4 + ) subq_1 GROUP BY - subq_4.listing__country_latest -) subq_5 -ORDER BY subq_5.listing__country_latest DESC + subq_1.listing__country_latest +) subq_2 +ORDER BY subq_2.listing__country_latest DESC LIMIT 100 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0_optimized.sql index 76e6591b6c..1653ada5bd 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_distinct_values__plan0_optimized.sql @@ -4,17 +4,11 @@ SELECT listing__country_latest FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - listing__country_latest - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - WHERE listing__country_latest = 'us' -) subq_7 + country AS listing__country_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_3 WHERE listing__country_latest = 'us' GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 e51209f538..32673ef241 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_19.metric_time__day - , CAST(subq_19.booking_value_with_is_instant_constraint AS DOUBLE PRECISION) / CAST(NULLIF(subq_19.booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_value_ratio + 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 FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day - , MAX(subq_13.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_18.booking_value) AS booking_value + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) AS metric_time__day + , MAX(subq_9.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_14.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.booking_value AS booking_value_with_is_instant_constraint + subq_8.metric_time__day + , subq_8.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.booking_value) AS booking_value + subq_7.metric_time__day + , SUM(subq_7.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_6.metric_time__day + , subq_6.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.booking_value + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking__is_instant - , subq_8.booking_value + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -329,134 +329,134 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 WHERE booking__is_instant - ) subq_10 - ) subq_11 + ) subq_6 + ) subq_7 GROUP BY - subq_11.metric_time__day - ) subq_12 - ) subq_13 + subq_7.metric_time__day + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day - , subq_17.booking_value + subq_13.metric_time__day + , subq_13.booking_value FROM ( -- Aggregate Measures SELECT - subq_16.metric_time__day - , SUM(subq_16.booking_value) AS booking_value + subq_12.metric_time__day + , SUM(subq_12.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_15.metric_time__day - , subq_15.booking_value + subq_11.metric_time__day + , subq_11.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_14.ds__day - , subq_14.ds__week - , subq_14.ds__month - , subq_14.ds__quarter - , subq_14.ds__year - , subq_14.ds__extract_year - , subq_14.ds__extract_quarter - , subq_14.ds__extract_month - , subq_14.ds__extract_day - , subq_14.ds__extract_dow - , subq_14.ds__extract_doy - , subq_14.ds_partitioned__day - , subq_14.ds_partitioned__week - , subq_14.ds_partitioned__month - , subq_14.ds_partitioned__quarter - , subq_14.ds_partitioned__year - , subq_14.ds_partitioned__extract_year - , subq_14.ds_partitioned__extract_quarter - , subq_14.ds_partitioned__extract_month - , subq_14.ds_partitioned__extract_day - , subq_14.ds_partitioned__extract_dow - , subq_14.ds_partitioned__extract_doy - , subq_14.paid_at__day - , subq_14.paid_at__week - , subq_14.paid_at__month - , subq_14.paid_at__quarter - , subq_14.paid_at__year - , subq_14.paid_at__extract_year - , subq_14.paid_at__extract_quarter - , subq_14.paid_at__extract_month - , subq_14.paid_at__extract_day - , subq_14.paid_at__extract_dow - , subq_14.paid_at__extract_doy - , subq_14.booking__ds__day - , subq_14.booking__ds__week - , subq_14.booking__ds__month - , subq_14.booking__ds__quarter - , subq_14.booking__ds__year - , subq_14.booking__ds__extract_year - , subq_14.booking__ds__extract_quarter - , subq_14.booking__ds__extract_month - , subq_14.booking__ds__extract_day - , subq_14.booking__ds__extract_dow - , subq_14.booking__ds__extract_doy - , subq_14.booking__ds_partitioned__day - , subq_14.booking__ds_partitioned__week - , subq_14.booking__ds_partitioned__month - , subq_14.booking__ds_partitioned__quarter - , subq_14.booking__ds_partitioned__year - , subq_14.booking__ds_partitioned__extract_year - , subq_14.booking__ds_partitioned__extract_quarter - , subq_14.booking__ds_partitioned__extract_month - , subq_14.booking__ds_partitioned__extract_day - , subq_14.booking__ds_partitioned__extract_dow - , subq_14.booking__ds_partitioned__extract_doy - , subq_14.booking__paid_at__day - , subq_14.booking__paid_at__week - , subq_14.booking__paid_at__month - , subq_14.booking__paid_at__quarter - , subq_14.booking__paid_at__year - , subq_14.booking__paid_at__extract_year - , subq_14.booking__paid_at__extract_quarter - , subq_14.booking__paid_at__extract_month - , subq_14.booking__paid_at__extract_day - , subq_14.booking__paid_at__extract_dow - , subq_14.booking__paid_at__extract_doy - , subq_14.ds__day AS metric_time__day - , subq_14.ds__week AS metric_time__week - , subq_14.ds__month AS metric_time__month - , subq_14.ds__quarter AS metric_time__quarter - , subq_14.ds__year AS metric_time__year - , subq_14.ds__extract_year AS metric_time__extract_year - , subq_14.ds__extract_quarter AS metric_time__extract_quarter - , subq_14.ds__extract_month AS metric_time__extract_month - , subq_14.ds__extract_day AS metric_time__extract_day - , subq_14.ds__extract_dow AS metric_time__extract_dow - , subq_14.ds__extract_doy AS metric_time__extract_doy - , subq_14.listing - , subq_14.guest - , subq_14.host - , subq_14.booking__listing - , subq_14.booking__guest - , subq_14.booking__host - , subq_14.is_instant - , subq_14.booking__is_instant - , subq_14.bookings - , subq_14.instant_bookings - , subq_14.booking_value - , subq_14.max_booking_value - , subq_14.min_booking_value - , subq_14.bookers - , subq_14.average_booking_value - , subq_14.referred_bookings - , subq_14.median_booking_value - , subq_14.booking_value_p99 - , subq_14.discrete_booking_value_p99 - , subq_14.approximate_continuous_booking_value_p99 - , subq_14.approximate_discrete_booking_value_p99 + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -549,15 +549,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 GROUP BY - subq_16.metric_time__day - ) subq_17 - ) subq_18 + subq_12.metric_time__day + ) subq_13 + ) subq_14 ON - subq_13.metric_time__day = subq_18.metric_time__day + subq_9.metric_time__day = subq_14.metric_time__day GROUP BY - COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) -) subq_19 + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) +) subq_15 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 29af02b578..9b1533b73c 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_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_27.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_32.booking_value) AS booking_value + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -31,13 +31,13 @@ FROM ( , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_21 + ) subq_17 WHERE booking__is_instant - ) subq_23 + ) subq_19 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_27 + ) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -50,9 +50,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_32 + ) subq_28 ON - subq_27.metric_time__day = subq_32.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) +) subq_29 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 882a6a8201..e6da332c04 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_13.metric_time__day + subq_9.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.bookings AS delayed_bookings + subq_8.metric_time__day + , subq_8.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.bookings) AS bookings + subq_7.metric_time__day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_6.metric_time__day + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.bookings + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking__is_instant - , subq_8.bookings + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -323,15 +323,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE NOT booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 WHERE NOT booking__is_instant - ) subq_10 - ) subq_11 + ) subq_6 + ) subq_7 GROUP BY - subq_11.metric_time__day - ) subq_12 -) subq_13 + subq_7.metric_time__day + ) subq_8 +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 33436b83b6..31360941eb 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_15 + ) subq_11 WHERE NOT booking__is_instant - ) subq_17 + ) subq_13 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_21 +) subq_17 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0.sql index 1c8af99bba..0a82b5e771 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0.sql @@ -1,195 +1,134 @@ -- Order By ['listing__country_latest'] Limit 100 SELECT - subq_5.listing__country_latest + subq_2.listing__country_latest FROM ( -- Pass Only Elements: ['listing__country_latest',] SELECT - subq_4.listing__country_latest + subq_1.listing__country_latest FROM ( -- Constrain Output with WHERE SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.created_at__day - , subq_3.created_at__week - , subq_3.created_at__month - , subq_3.created_at__quarter - , subq_3.created_at__year - , subq_3.created_at__extract_year - , subq_3.created_at__extract_quarter - , subq_3.created_at__extract_month - , subq_3.created_at__extract_day - , subq_3.created_at__extract_dow - , subq_3.created_at__extract_doy - , subq_3.listing__ds__day - , subq_3.listing__ds__week - , subq_3.listing__ds__month - , subq_3.listing__ds__quarter - , subq_3.listing__ds__year - , subq_3.listing__ds__extract_year - , subq_3.listing__ds__extract_quarter - , subq_3.listing__ds__extract_month - , subq_3.listing__ds__extract_day - , subq_3.listing__ds__extract_dow - , subq_3.listing__ds__extract_doy - , subq_3.listing__created_at__day - , subq_3.listing__created_at__week - , subq_3.listing__created_at__month - , subq_3.listing__created_at__quarter - , subq_3.listing__created_at__year - , subq_3.listing__created_at__extract_year - , subq_3.listing__created_at__extract_quarter - , subq_3.listing__created_at__extract_month - , subq_3.listing__created_at__extract_day - , subq_3.listing__created_at__extract_dow - , subq_3.listing__created_at__extract_doy - , subq_3.listing - , subq_3.user - , subq_3.listing__user - , subq_3.country_latest - , subq_3.is_lux_latest - , subq_3.capacity_latest - , subq_3.listing__country_latest - , subq_3.listing__is_lux_latest - , subq_3.listing__capacity_latest - , subq_3.listings - , subq_3.largest_listing - , subq_3.smallest_listing + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_2.ds__day - , subq_2.ds__week - , subq_2.ds__month - , subq_2.ds__quarter - , subq_2.ds__year - , subq_2.ds__extract_year - , subq_2.ds__extract_quarter - , subq_2.ds__extract_month - , subq_2.ds__extract_day - , subq_2.ds__extract_dow - , subq_2.ds__extract_doy - , subq_2.created_at__day - , subq_2.created_at__week - , subq_2.created_at__month - , subq_2.created_at__quarter - , subq_2.created_at__year - , subq_2.created_at__extract_year - , subq_2.created_at__extract_quarter - , subq_2.created_at__extract_month - , subq_2.created_at__extract_day - , subq_2.created_at__extract_dow - , subq_2.created_at__extract_doy - , subq_2.listing__ds__day - , subq_2.listing__ds__week - , subq_2.listing__ds__month - , subq_2.listing__ds__quarter - , subq_2.listing__ds__year - , subq_2.listing__ds__extract_year - , subq_2.listing__ds__extract_quarter - , subq_2.listing__ds__extract_month - , subq_2.listing__ds__extract_day - , subq_2.listing__ds__extract_dow - , subq_2.listing__ds__extract_doy - , subq_2.listing__created_at__day - , subq_2.listing__created_at__week - , subq_2.listing__created_at__month - , subq_2.listing__created_at__quarter - , subq_2.listing__created_at__year - , subq_2.listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month - , subq_2.listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy - , subq_2.listing - , subq_2.user - , subq_2.listing__user - , subq_2.country_latest - , subq_2.is_lux_latest - , subq_2.capacity_latest - , subq_2.listing__country_latest - , subq_2.listing__is_lux_latest - , subq_2.listing__capacity_latest - , subq_2.listings - , subq_2.largest_listing - , subq_2.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 - WHERE listing__country_latest = 'us' - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 WHERE listing__country_latest = 'us' - ) subq_4 + ) subq_1 GROUP BY - subq_4.listing__country_latest -) subq_5 -ORDER BY subq_5.listing__country_latest DESC + subq_1.listing__country_latest +) subq_2 +ORDER BY subq_2.listing__country_latest DESC LIMIT 100 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0_optimized.sql index 76e6591b6c..1653ada5bd 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0_optimized.sql @@ -4,17 +4,11 @@ SELECT listing__country_latest FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - listing__country_latest - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - WHERE listing__country_latest = 'us' -) subq_7 + country AS listing__country_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_3 WHERE listing__country_latest = 'us' GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 41e951d762..b83572690f 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_19.metric_time__day - , CAST(subq_19.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_19.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio + subq_15.metric_time__day + , CAST(subq_15.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_15.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day - , MAX(subq_13.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_18.booking_value) AS booking_value + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) AS metric_time__day + , MAX(subq_9.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_14.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.booking_value AS booking_value_with_is_instant_constraint + subq_8.metric_time__day + , subq_8.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.booking_value) AS booking_value + subq_7.metric_time__day + , SUM(subq_7.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_6.metric_time__day + , subq_6.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.booking_value + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking__is_instant - , subq_8.booking_value + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -329,134 +329,134 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 WHERE booking__is_instant - ) subq_10 - ) subq_11 + ) subq_6 + ) subq_7 GROUP BY - subq_11.metric_time__day - ) subq_12 - ) subq_13 + subq_7.metric_time__day + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day - , subq_17.booking_value + subq_13.metric_time__day + , subq_13.booking_value FROM ( -- Aggregate Measures SELECT - subq_16.metric_time__day - , SUM(subq_16.booking_value) AS booking_value + subq_12.metric_time__day + , SUM(subq_12.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_15.metric_time__day - , subq_15.booking_value + subq_11.metric_time__day + , subq_11.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_14.ds__day - , subq_14.ds__week - , subq_14.ds__month - , subq_14.ds__quarter - , subq_14.ds__year - , subq_14.ds__extract_year - , subq_14.ds__extract_quarter - , subq_14.ds__extract_month - , subq_14.ds__extract_day - , subq_14.ds__extract_dow - , subq_14.ds__extract_doy - , subq_14.ds_partitioned__day - , subq_14.ds_partitioned__week - , subq_14.ds_partitioned__month - , subq_14.ds_partitioned__quarter - , subq_14.ds_partitioned__year - , subq_14.ds_partitioned__extract_year - , subq_14.ds_partitioned__extract_quarter - , subq_14.ds_partitioned__extract_month - , subq_14.ds_partitioned__extract_day - , subq_14.ds_partitioned__extract_dow - , subq_14.ds_partitioned__extract_doy - , subq_14.paid_at__day - , subq_14.paid_at__week - , subq_14.paid_at__month - , subq_14.paid_at__quarter - , subq_14.paid_at__year - , subq_14.paid_at__extract_year - , subq_14.paid_at__extract_quarter - , subq_14.paid_at__extract_month - , subq_14.paid_at__extract_day - , subq_14.paid_at__extract_dow - , subq_14.paid_at__extract_doy - , subq_14.booking__ds__day - , subq_14.booking__ds__week - , subq_14.booking__ds__month - , subq_14.booking__ds__quarter - , subq_14.booking__ds__year - , subq_14.booking__ds__extract_year - , subq_14.booking__ds__extract_quarter - , subq_14.booking__ds__extract_month - , subq_14.booking__ds__extract_day - , subq_14.booking__ds__extract_dow - , subq_14.booking__ds__extract_doy - , subq_14.booking__ds_partitioned__day - , subq_14.booking__ds_partitioned__week - , subq_14.booking__ds_partitioned__month - , subq_14.booking__ds_partitioned__quarter - , subq_14.booking__ds_partitioned__year - , subq_14.booking__ds_partitioned__extract_year - , subq_14.booking__ds_partitioned__extract_quarter - , subq_14.booking__ds_partitioned__extract_month - , subq_14.booking__ds_partitioned__extract_day - , subq_14.booking__ds_partitioned__extract_dow - , subq_14.booking__ds_partitioned__extract_doy - , subq_14.booking__paid_at__day - , subq_14.booking__paid_at__week - , subq_14.booking__paid_at__month - , subq_14.booking__paid_at__quarter - , subq_14.booking__paid_at__year - , subq_14.booking__paid_at__extract_year - , subq_14.booking__paid_at__extract_quarter - , subq_14.booking__paid_at__extract_month - , subq_14.booking__paid_at__extract_day - , subq_14.booking__paid_at__extract_dow - , subq_14.booking__paid_at__extract_doy - , subq_14.ds__day AS metric_time__day - , subq_14.ds__week AS metric_time__week - , subq_14.ds__month AS metric_time__month - , subq_14.ds__quarter AS metric_time__quarter - , subq_14.ds__year AS metric_time__year - , subq_14.ds__extract_year AS metric_time__extract_year - , subq_14.ds__extract_quarter AS metric_time__extract_quarter - , subq_14.ds__extract_month AS metric_time__extract_month - , subq_14.ds__extract_day AS metric_time__extract_day - , subq_14.ds__extract_dow AS metric_time__extract_dow - , subq_14.ds__extract_doy AS metric_time__extract_doy - , subq_14.listing - , subq_14.guest - , subq_14.host - , subq_14.booking__listing - , subq_14.booking__guest - , subq_14.booking__host - , subq_14.is_instant - , subq_14.booking__is_instant - , subq_14.bookings - , subq_14.instant_bookings - , subq_14.booking_value - , subq_14.max_booking_value - , subq_14.min_booking_value - , subq_14.bookers - , subq_14.average_booking_value - , subq_14.referred_bookings - , subq_14.median_booking_value - , subq_14.booking_value_p99 - , subq_14.discrete_booking_value_p99 - , subq_14.approximate_continuous_booking_value_p99 - , subq_14.approximate_discrete_booking_value_p99 + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -549,15 +549,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 GROUP BY - subq_16.metric_time__day - ) subq_17 - ) subq_18 + subq_12.metric_time__day + ) subq_13 + ) subq_14 ON - subq_13.metric_time__day = subq_18.metric_time__day + subq_9.metric_time__day = subq_14.metric_time__day GROUP BY - COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) -) subq_19 + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) +) subq_15 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 f0def82955..b3f811ac19 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_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_27.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_32.booking_value) AS booking_value + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -31,13 +31,13 @@ FROM ( , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_21 + ) subq_17 WHERE booking__is_instant - ) subq_23 + ) subq_19 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_27 + ) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -50,9 +50,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_32 + ) subq_28 ON - subq_27.metric_time__day = subq_32.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) +) subq_29 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 65a868eb42..bb5826ee1e 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_13.metric_time__day + subq_9.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.bookings AS delayed_bookings + subq_8.metric_time__day + , subq_8.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.bookings) AS bookings + subq_7.metric_time__day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_6.metric_time__day + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.bookings + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking__is_instant - , subq_8.bookings + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -323,15 +323,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE NOT booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 WHERE NOT booking__is_instant - ) subq_10 - ) subq_11 + ) subq_6 + ) subq_7 GROUP BY - subq_11.metric_time__day - ) subq_12 -) subq_13 + subq_7.metric_time__day + ) subq_8 +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 33436b83b6..31360941eb 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_15 + ) subq_11 WHERE NOT booking__is_instant - ) subq_17 + ) subq_13 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_21 +) subq_17 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_distinct_values__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_distinct_values__plan0.sql index c77e8402bb..955c17a477 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_distinct_values__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_distinct_values__plan0.sql @@ -1,195 +1,134 @@ -- Order By ['listing__country_latest'] Limit 100 SELECT - subq_5.listing__country_latest + subq_2.listing__country_latest FROM ( -- Pass Only Elements: ['listing__country_latest',] SELECT - subq_4.listing__country_latest + subq_1.listing__country_latest FROM ( -- Constrain Output with WHERE SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.created_at__day - , subq_3.created_at__week - , subq_3.created_at__month - , subq_3.created_at__quarter - , subq_3.created_at__year - , subq_3.created_at__extract_year - , subq_3.created_at__extract_quarter - , subq_3.created_at__extract_month - , subq_3.created_at__extract_day - , subq_3.created_at__extract_dow - , subq_3.created_at__extract_doy - , subq_3.listing__ds__day - , subq_3.listing__ds__week - , subq_3.listing__ds__month - , subq_3.listing__ds__quarter - , subq_3.listing__ds__year - , subq_3.listing__ds__extract_year - , subq_3.listing__ds__extract_quarter - , subq_3.listing__ds__extract_month - , subq_3.listing__ds__extract_day - , subq_3.listing__ds__extract_dow - , subq_3.listing__ds__extract_doy - , subq_3.listing__created_at__day - , subq_3.listing__created_at__week - , subq_3.listing__created_at__month - , subq_3.listing__created_at__quarter - , subq_3.listing__created_at__year - , subq_3.listing__created_at__extract_year - , subq_3.listing__created_at__extract_quarter - , subq_3.listing__created_at__extract_month - , subq_3.listing__created_at__extract_day - , subq_3.listing__created_at__extract_dow - , subq_3.listing__created_at__extract_doy - , subq_3.listing - , subq_3.user - , subq_3.listing__user - , subq_3.country_latest - , subq_3.is_lux_latest - , subq_3.capacity_latest - , subq_3.listing__country_latest - , subq_3.listing__is_lux_latest - , subq_3.listing__capacity_latest - , subq_3.listings - , subq_3.largest_listing - , subq_3.smallest_listing + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_2.ds__day - , subq_2.ds__week - , subq_2.ds__month - , subq_2.ds__quarter - , subq_2.ds__year - , subq_2.ds__extract_year - , subq_2.ds__extract_quarter - , subq_2.ds__extract_month - , subq_2.ds__extract_day - , subq_2.ds__extract_dow - , subq_2.ds__extract_doy - , subq_2.created_at__day - , subq_2.created_at__week - , subq_2.created_at__month - , subq_2.created_at__quarter - , subq_2.created_at__year - , subq_2.created_at__extract_year - , subq_2.created_at__extract_quarter - , subq_2.created_at__extract_month - , subq_2.created_at__extract_day - , subq_2.created_at__extract_dow - , subq_2.created_at__extract_doy - , subq_2.listing__ds__day - , subq_2.listing__ds__week - , subq_2.listing__ds__month - , subq_2.listing__ds__quarter - , subq_2.listing__ds__year - , subq_2.listing__ds__extract_year - , subq_2.listing__ds__extract_quarter - , subq_2.listing__ds__extract_month - , subq_2.listing__ds__extract_day - , subq_2.listing__ds__extract_dow - , subq_2.listing__ds__extract_doy - , subq_2.listing__created_at__day - , subq_2.listing__created_at__week - , subq_2.listing__created_at__month - , subq_2.listing__created_at__quarter - , subq_2.listing__created_at__year - , subq_2.listing__created_at__extract_year - , subq_2.listing__created_at__extract_quarter - , subq_2.listing__created_at__extract_month - , subq_2.listing__created_at__extract_day - , subq_2.listing__created_at__extract_dow - , subq_2.listing__created_at__extract_doy - , subq_2.listing - , subq_2.user - , subq_2.listing__user - , subq_2.country_latest - , subq_2.is_lux_latest - , subq_2.capacity_latest - , subq_2.listing__country_latest - , subq_2.listing__is_lux_latest - , subq_2.listing__capacity_latest - , subq_2.listings - , subq_2.largest_listing - , subq_2.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_2 - WHERE listing__country_latest = 'us' - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 WHERE listing__country_latest = 'us' - ) subq_4 + ) subq_1 GROUP BY - subq_4.listing__country_latest -) subq_5 -ORDER BY subq_5.listing__country_latest DESC + subq_1.listing__country_latest +) subq_2 +ORDER BY subq_2.listing__country_latest DESC LIMIT 100 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_distinct_values__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_distinct_values__plan0_optimized.sql index 76e6591b6c..1653ada5bd 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_distinct_values__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_distinct_values__plan0_optimized.sql @@ -4,17 +4,11 @@ SELECT listing__country_latest FROM ( - -- Constrain Output with WHERE + -- Read Elements From Semantic Model 'listings_latest' SELECT - listing__country_latest - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - country AS listing__country_latest - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - WHERE listing__country_latest = 'us' -) subq_7 + country AS listing__country_latest + FROM ***************************.dim_listings_latest listings_latest_src_28000 +) subq_3 WHERE listing__country_latest = 'us' GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 dd97f89d8f..8df9db1cbe 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_19.metric_time__day - , CAST(subq_19.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_19.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio + subq_15.metric_time__day + , CAST(subq_15.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_15.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) AS metric_time__day - , MAX(subq_13.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_18.booking_value) AS booking_value + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) AS metric_time__day + , MAX(subq_9.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_14.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.booking_value AS booking_value_with_is_instant_constraint + subq_8.metric_time__day + , subq_8.booking_value AS booking_value_with_is_instant_constraint FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.booking_value) AS booking_value + subq_7.metric_time__day + , SUM(subq_7.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_6.metric_time__day + , subq_6.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.booking_value + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking__is_instant - , subq_8.booking_value + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -329,134 +329,134 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 WHERE booking__is_instant - ) subq_10 - ) subq_11 + ) subq_6 + ) subq_7 GROUP BY - subq_11.metric_time__day - ) subq_12 - ) subq_13 + subq_7.metric_time__day + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_17.metric_time__day - , subq_17.booking_value + subq_13.metric_time__day + , subq_13.booking_value FROM ( -- Aggregate Measures SELECT - subq_16.metric_time__day - , SUM(subq_16.booking_value) AS booking_value + subq_12.metric_time__day + , SUM(subq_12.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day'] SELECT - subq_15.metric_time__day - , subq_15.booking_value + subq_11.metric_time__day + , subq_11.booking_value FROM ( -- Metric Time Dimension 'ds' SELECT - subq_14.ds__day - , subq_14.ds__week - , subq_14.ds__month - , subq_14.ds__quarter - , subq_14.ds__year - , subq_14.ds__extract_year - , subq_14.ds__extract_quarter - , subq_14.ds__extract_month - , subq_14.ds__extract_day - , subq_14.ds__extract_dow - , subq_14.ds__extract_doy - , subq_14.ds_partitioned__day - , subq_14.ds_partitioned__week - , subq_14.ds_partitioned__month - , subq_14.ds_partitioned__quarter - , subq_14.ds_partitioned__year - , subq_14.ds_partitioned__extract_year - , subq_14.ds_partitioned__extract_quarter - , subq_14.ds_partitioned__extract_month - , subq_14.ds_partitioned__extract_day - , subq_14.ds_partitioned__extract_dow - , subq_14.ds_partitioned__extract_doy - , subq_14.paid_at__day - , subq_14.paid_at__week - , subq_14.paid_at__month - , subq_14.paid_at__quarter - , subq_14.paid_at__year - , subq_14.paid_at__extract_year - , subq_14.paid_at__extract_quarter - , subq_14.paid_at__extract_month - , subq_14.paid_at__extract_day - , subq_14.paid_at__extract_dow - , subq_14.paid_at__extract_doy - , subq_14.booking__ds__day - , subq_14.booking__ds__week - , subq_14.booking__ds__month - , subq_14.booking__ds__quarter - , subq_14.booking__ds__year - , subq_14.booking__ds__extract_year - , subq_14.booking__ds__extract_quarter - , subq_14.booking__ds__extract_month - , subq_14.booking__ds__extract_day - , subq_14.booking__ds__extract_dow - , subq_14.booking__ds__extract_doy - , subq_14.booking__ds_partitioned__day - , subq_14.booking__ds_partitioned__week - , subq_14.booking__ds_partitioned__month - , subq_14.booking__ds_partitioned__quarter - , subq_14.booking__ds_partitioned__year - , subq_14.booking__ds_partitioned__extract_year - , subq_14.booking__ds_partitioned__extract_quarter - , subq_14.booking__ds_partitioned__extract_month - , subq_14.booking__ds_partitioned__extract_day - , subq_14.booking__ds_partitioned__extract_dow - , subq_14.booking__ds_partitioned__extract_doy - , subq_14.booking__paid_at__day - , subq_14.booking__paid_at__week - , subq_14.booking__paid_at__month - , subq_14.booking__paid_at__quarter - , subq_14.booking__paid_at__year - , subq_14.booking__paid_at__extract_year - , subq_14.booking__paid_at__extract_quarter - , subq_14.booking__paid_at__extract_month - , subq_14.booking__paid_at__extract_day - , subq_14.booking__paid_at__extract_dow - , subq_14.booking__paid_at__extract_doy - , subq_14.ds__day AS metric_time__day - , subq_14.ds__week AS metric_time__week - , subq_14.ds__month AS metric_time__month - , subq_14.ds__quarter AS metric_time__quarter - , subq_14.ds__year AS metric_time__year - , subq_14.ds__extract_year AS metric_time__extract_year - , subq_14.ds__extract_quarter AS metric_time__extract_quarter - , subq_14.ds__extract_month AS metric_time__extract_month - , subq_14.ds__extract_day AS metric_time__extract_day - , subq_14.ds__extract_dow AS metric_time__extract_dow - , subq_14.ds__extract_doy AS metric_time__extract_doy - , subq_14.listing - , subq_14.guest - , subq_14.host - , subq_14.booking__listing - , subq_14.booking__guest - , subq_14.booking__host - , subq_14.is_instant - , subq_14.booking__is_instant - , subq_14.bookings - , subq_14.instant_bookings - , subq_14.booking_value - , subq_14.max_booking_value - , subq_14.min_booking_value - , subq_14.bookers - , subq_14.average_booking_value - , subq_14.referred_bookings - , subq_14.median_booking_value - , subq_14.booking_value_p99 - , subq_14.discrete_booking_value_p99 - , subq_14.approximate_continuous_booking_value_p99 - , subq_14.approximate_discrete_booking_value_p99 + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -549,15 +549,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_14 - ) subq_15 - ) subq_16 + ) subq_10 + ) subq_11 + ) subq_12 GROUP BY - subq_16.metric_time__day - ) subq_17 - ) subq_18 + subq_12.metric_time__day + ) subq_13 + ) subq_14 ON - subq_13.metric_time__day = subq_18.metric_time__day + subq_9.metric_time__day = subq_14.metric_time__day GROUP BY - COALESCE(subq_13.metric_time__day, subq_18.metric_time__day) -) subq_19 + COALESCE(subq_9.metric_time__day, subq_14.metric_time__day) +) subq_15 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 f0def82955..b3f811ac19 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_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , MAX(subq_27.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint - , MAX(subq_32.booking_value) AS booking_value + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , MAX(subq_23.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -31,13 +31,13 @@ FROM ( , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_21 + ) subq_17 WHERE booking__is_instant - ) subq_23 + ) subq_19 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_27 + ) subq_23 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -50,9 +50,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_32 + ) subq_28 ON - subq_27.metric_time__day = subq_32.metric_time__day + subq_23.metric_time__day = subq_28.metric_time__day GROUP BY - COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) -) subq_33 + COALESCE(subq_23.metric_time__day, subq_28.metric_time__day) +) subq_29 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 9b8d9efeee..70a6055760 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_13.metric_time__day + subq_9.metric_time__day , delayed_bookings * 2 AS double_counted_delayed_bookings FROM ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , subq_12.bookings AS delayed_bookings + subq_8.metric_time__day + , subq_8.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__day - , SUM(subq_11.bookings) AS bookings + subq_7.metric_time__day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_6.metric_time__day + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.bookings + subq_5.metric_time__day + , subq_5.booking__is_instant + , subq_5.bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.booking__is_instant - , subq_8.bookings + subq_4.metric_time__day + , subq_4.booking__is_instant + , subq_4.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.ds_partitioned__day - , subq_7.ds_partitioned__week - , subq_7.ds_partitioned__month - , subq_7.ds_partitioned__quarter - , subq_7.ds_partitioned__year - , subq_7.ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy - , subq_7.paid_at__day - , subq_7.paid_at__week - , subq_7.paid_at__month - , subq_7.paid_at__quarter - , subq_7.paid_at__year - , subq_7.paid_at__extract_year - , subq_7.paid_at__extract_quarter - , subq_7.paid_at__extract_month - , subq_7.paid_at__extract_day - , subq_7.paid_at__extract_dow - , subq_7.paid_at__extract_doy - , subq_7.booking__ds__day - , subq_7.booking__ds__week - , subq_7.booking__ds__month - , subq_7.booking__ds__quarter - , subq_7.booking__ds__year - , subq_7.booking__ds__extract_year - , subq_7.booking__ds__extract_quarter - , subq_7.booking__ds__extract_month - , subq_7.booking__ds__extract_day - , subq_7.booking__ds__extract_dow - , subq_7.booking__ds__extract_doy - , subq_7.booking__ds_partitioned__day - , subq_7.booking__ds_partitioned__week - , subq_7.booking__ds_partitioned__month - , subq_7.booking__ds_partitioned__quarter - , subq_7.booking__ds_partitioned__year - , subq_7.booking__ds_partitioned__extract_year - , subq_7.booking__ds_partitioned__extract_quarter - , subq_7.booking__ds_partitioned__extract_month - , subq_7.booking__ds_partitioned__extract_day - , subq_7.booking__ds_partitioned__extract_dow - , subq_7.booking__ds_partitioned__extract_doy - , subq_7.booking__paid_at__day - , subq_7.booking__paid_at__week - , subq_7.booking__paid_at__month - , subq_7.booking__paid_at__quarter - , subq_7.booking__paid_at__year - , subq_7.booking__paid_at__extract_year - , subq_7.booking__paid_at__extract_quarter - , subq_7.booking__paid_at__extract_month - , subq_7.booking__paid_at__extract_day - , subq_7.booking__paid_at__extract_dow - , subq_7.booking__paid_at__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.listing - , subq_7.guest - , subq_7.host - , subq_7.booking__listing - , subq_7.booking__guest - , subq_7.booking__host - , subq_7.is_instant - , subq_7.booking__is_instant - , subq_7.bookings - , subq_7.instant_bookings - , subq_7.booking_value - , subq_7.max_booking_value - , subq_7.min_booking_value - , subq_7.bookers - , subq_7.average_booking_value - , subq_7.referred_bookings - , subq_7.median_booking_value - , subq_7.booking_value_p99 - , subq_7.discrete_booking_value_p99 - , subq_7.approximate_continuous_booking_value_p99 - , subq_7.approximate_discrete_booking_value_p99 + subq_3.ds__day + , subq_3.ds__week + , subq_3.ds__month + , subq_3.ds__quarter + , subq_3.ds__year + , subq_3.ds__extract_year + , subq_3.ds__extract_quarter + , subq_3.ds__extract_month + , subq_3.ds__extract_day + , subq_3.ds__extract_dow + , subq_3.ds__extract_doy + , subq_3.ds_partitioned__day + , subq_3.ds_partitioned__week + , subq_3.ds_partitioned__month + , subq_3.ds_partitioned__quarter + , subq_3.ds_partitioned__year + , subq_3.ds_partitioned__extract_year + , subq_3.ds_partitioned__extract_quarter + , subq_3.ds_partitioned__extract_month + , subq_3.ds_partitioned__extract_day + , subq_3.ds_partitioned__extract_dow + , subq_3.ds_partitioned__extract_doy + , subq_3.paid_at__day + , subq_3.paid_at__week + , subq_3.paid_at__month + , subq_3.paid_at__quarter + , subq_3.paid_at__year + , subq_3.paid_at__extract_year + , subq_3.paid_at__extract_quarter + , subq_3.paid_at__extract_month + , subq_3.paid_at__extract_day + , subq_3.paid_at__extract_dow + , subq_3.paid_at__extract_doy + , subq_3.booking__ds__day + , subq_3.booking__ds__week + , subq_3.booking__ds__month + , subq_3.booking__ds__quarter + , subq_3.booking__ds__year + , subq_3.booking__ds__extract_year + , subq_3.booking__ds__extract_quarter + , subq_3.booking__ds__extract_month + , subq_3.booking__ds__extract_day + , subq_3.booking__ds__extract_dow + , subq_3.booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day + , subq_3.booking__paid_at__week + , subq_3.booking__paid_at__month + , subq_3.booking__paid_at__quarter + , subq_3.booking__paid_at__year + , subq_3.booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.listing + , subq_3.guest + , subq_3.host + , subq_3.booking__listing + , subq_3.booking__guest + , subq_3.booking__host + , subq_3.is_instant + , subq_3.booking__is_instant + , subq_3.bookings + , subq_3.instant_bookings + , subq_3.booking_value + , subq_3.max_booking_value + , subq_3.min_booking_value + , subq_3.bookers + , subq_3.average_booking_value + , subq_3.referred_bookings + , subq_3.median_booking_value + , subq_3.booking_value_p99 + , subq_3.discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT - subq_6.ds__day - , subq_6.ds__week - , subq_6.ds__month - , subq_6.ds__quarter - , subq_6.ds__year - , subq_6.ds__extract_year - , subq_6.ds__extract_quarter - , subq_6.ds__extract_month - , subq_6.ds__extract_day - , subq_6.ds__extract_dow - , subq_6.ds__extract_doy - , subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.paid_at__day - , subq_6.paid_at__week - , subq_6.paid_at__month - , subq_6.paid_at__quarter - , subq_6.paid_at__year - , subq_6.paid_at__extract_year - , subq_6.paid_at__extract_quarter - , subq_6.paid_at__extract_month - , subq_6.paid_at__extract_day - , subq_6.paid_at__extract_dow - , subq_6.paid_at__extract_doy - , subq_6.booking__ds__day - , subq_6.booking__ds__week - , subq_6.booking__ds__month - , subq_6.booking__ds__quarter - , subq_6.booking__ds__year - , subq_6.booking__ds__extract_year - , subq_6.booking__ds__extract_quarter - , subq_6.booking__ds__extract_month - , subq_6.booking__ds__extract_day - , subq_6.booking__ds__extract_dow - , subq_6.booking__ds__extract_doy - , subq_6.booking__ds_partitioned__day - , subq_6.booking__ds_partitioned__week - , subq_6.booking__ds_partitioned__month - , subq_6.booking__ds_partitioned__quarter - , subq_6.booking__ds_partitioned__year - , subq_6.booking__ds_partitioned__extract_year - , subq_6.booking__ds_partitioned__extract_quarter - , subq_6.booking__ds_partitioned__extract_month - , subq_6.booking__ds_partitioned__extract_day - , subq_6.booking__ds_partitioned__extract_dow - , subq_6.booking__ds_partitioned__extract_doy - , subq_6.booking__paid_at__day - , subq_6.booking__paid_at__week - , subq_6.booking__paid_at__month - , subq_6.booking__paid_at__quarter - , subq_6.booking__paid_at__year - , subq_6.booking__paid_at__extract_year - , subq_6.booking__paid_at__extract_quarter - , subq_6.booking__paid_at__extract_month - , subq_6.booking__paid_at__extract_day - , subq_6.booking__paid_at__extract_dow - , subq_6.booking__paid_at__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.listing - , subq_6.guest - , subq_6.host - , subq_6.booking__listing - , subq_6.booking__guest - , subq_6.booking__host - , subq_6.is_instant - , subq_6.booking__is_instant - , subq_6.bookings - , subq_6.instant_bookings - , subq_6.booking_value - , subq_6.max_booking_value - , subq_6.min_booking_value - , subq_6.bookers - , subq_6.average_booking_value - , subq_6.referred_bookings - , subq_6.median_booking_value - , subq_6.booking_value_p99 - , subq_6.discrete_booking_value_p99 - , subq_6.approximate_continuous_booking_value_p99 - , subq_6.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -323,15 +323,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_2 + ) subq_3 WHERE NOT booking__is_instant - ) subq_8 - ) subq_9 + ) subq_4 + ) subq_5 WHERE NOT booking__is_instant - ) subq_10 - ) subq_11 + ) subq_6 + ) subq_7 GROUP BY - subq_11.metric_time__day - ) subq_12 -) subq_13 + subq_7.metric_time__day + ) subq_8 +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/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 33436b83b6..31360941eb 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_15 + ) subq_11 WHERE NOT booking__is_instant - ) subq_17 + ) subq_13 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_21 +) subq_17